• Resolved mykhaylopetrov

    (@mykhaylopetrov)


    I want to translate all form fields into several languages. I used the following hook for the “Name” field:

    function wpf_dev_name_field_properties( $properties, $field, $form_data ) {
    
        if ( absint( $form_data['id'] ) !== 755 ) {
            return $properties;
        }
    
        if ( get_locale() == 'ru_RU' ) {
            $properties['label']['value'] = 'Напишите свое имя';
            $properties['inputs']['primary']['attr']['placeholder'] = 'Например: Станислав';
        } elseif ( get_locale() == 'en_US' ) {
            $properties['label']['value'] = 'Enter your name';
            $properties['inputs']['primary']['attr']['placeholder'] = 'For example: Stanislav';
        }
    
        return $properties;
    
    }
    add_filter( 'wpforms_field_properties_name' , 'wpf_dev_name_field_properties', 10, 3 );

    How can I similarly translate the “Placeholder” and “Label” attributes in the “Dropdown” and “Single Line Text” fields? Tried the “wpforms_field_properties” hook, but it does not have these fields in the $properties variable.

Viewing 1 replies (of 1 total)
  • Hello @mykhaylopetrov,

    Thanks for writing in!

    You should be able to use the filter wpforms_field_properties_text for the Single Line Text field.

    However, we currently do not have a specific field to use for the Dropdown field, but you can look into the wpforms_field_properties as it should also work.

    And in case it helps, you can find more details in the dev doc guide.

    I hope this helps you get started.

    Thanks!

Viewing 1 replies (of 1 total)
  • The topic ‘Get the attributes in the “Dropdown” and “Single Line Text” fields’ is closed to new replies.