• Hi …
    I am trying to change the looks of input fields based on some conditions in my code. It does not work as expected.

    my code.

    add_filter('ninja_forms_render_default_value', array(__CLASS__, 'my_change_values'), 10, 3);
    add_filter('ninja_forms_localize_fields', array(__CLASS__, 'my_change_settings'), 10, 1);
    public static function my_change_values($value, $field_type, $field_settings) {
        if ($field_settings['key'] == 'my_key') {
            $value = "C1234556"; //WORKS
        }
        return $value;
    }
    public static function my_change_settings($field) {
        if ($field['settings']['key'] == 'my_key') {
            $field['settings']['disable_input'] = true; //WORKS
            $field['settings']['label'] = 'yada'; //WORKS
            $field['settings']['required'] = false; //WORKS
            $field['settings']['element_styles_background-color'] = '#ccc'; //WORKS NOT
            $field['settings']['element_styles_border-style'] = 'dotted'; //WORKS NOT
        }
        return $field;
    }

    I would expect the field to have a dotted border and grey background which it does not. Changing it in the builder works and a dump of the field shows the correct values. When I try to override a value which was set in builder and shows up correctly on the site, I have the new value in the dump but the frontend shows the value from the builder. Changing the priority does not help and I do not have other code active interfering with this filter.

    Any ideas?

    Thanks

  • The topic ‘Dynamically change values AND looks’ is closed to new replies.