| @@ -106,8 +106,12 @@ | ||
| 106 | 106 | 'placeholder' => [ |
| 107 | 107 | 'type' => 'string', |
| 108 | 108 | 'description' => __( 'Placeholder text shown inside the empty input/textarea or as the empty first option in a dropdown.', 'sureforms' ), |
| 109 | 109 | ], |
| 110 | + 'className' => [ | |
| 111 | + 'type' => 'string', | |
| 112 | + 'description' => __( 'Additional CSS class(es) for the field wrapper. Space-separate multiple classes, e.g. "vk-0 highlight".', 'sureforms' ), | |
| 113 | + ], | |
| 110 | 114 | ]; |
| 111 | 115 | |
| 112 | 116 | /** |
| 113 | 117 | * Filter additional field properties for form ability schemas. |
| @@ -149,8 +153,14 @@ | ||
| 149 | 153 | $fields[ $index ]['defaultValue'] = sanitize_text_field( $field['defaultValue'] ); |
| 150 | 154 | } |
| 151 | 155 | if ( isset( $field['placeholder'] ) && is_string( $field['placeholder'] ) ) { |
| 152 | 156 | $fields[ $index ]['placeholder'] = sanitize_text_field( $field['placeholder'] ); |
| 157 | + } | |
| 158 | + if ( isset( $field['className'] ) && is_string( $field['className'] ) ) { | |
| 159 | + $classes = preg_split( '/\s+/', trim( $field['className'] ) ); | |
| 160 | + $fields[ $index ]['className'] = is_array( $classes ) | |
| 161 | + ? implode( ' ', array_filter( array_map( 'sanitize_html_class', $classes ) ) ) | |
| 162 | + : ''; | |
| 153 | 163 | } |
| 154 | 164 | if ( ! empty( $field['fieldOptions'] ) && is_array( $field['fieldOptions'] ) ) { |
| 155 | 165 | // @phpstan-ignore-next-line -- $field['fieldOptions'] is validated as array above. |
| 156 | 166 | $field_options = $field['fieldOptions']; |