| @@ -101,8 +101,17 @@ | ||
| 101 | 101 | 'textLength' => [ |
| 102 | 102 | 'type' => 'integer', |
| 103 | 103 | 'description' => __( 'Maximum character length.', 'sureforms' ), |
| 104 | 104 | ], |
| 105 | + // `placeholder` — @since 2.10.0 (added alongside the HTML-form converter) | |
| 106 | + 'placeholder' => [ | |
| 107 | + 'type' => 'string', | |
| 108 | + 'description' => __( 'Placeholder text shown inside the empty input/textarea or as the empty first option in a dropdown.', 'sureforms' ), | |
| 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 | + ], | |
| 105 | 114 | ]; |
| 106 | 115 | |
| 107 | 116 | /** |
| 108 | 117 | * Filter additional field properties for form ability schemas. |
| @@ -141,8 +150,17 @@ | ||
| 141 | 150 | $fields[ $index ]['helpText'] = sanitize_text_field( $field['helpText'] ); |
| 142 | 151 | } |
| 143 | 152 | if ( isset( $field['defaultValue'] ) && is_string( $field['defaultValue'] ) ) { |
| 144 | 153 | $fields[ $index ]['defaultValue'] = sanitize_text_field( $field['defaultValue'] ); |
| 154 | + } | |
| 155 | + if ( isset( $field['placeholder'] ) && is_string( $field['placeholder'] ) ) { | |
| 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 | + : ''; | |
| 145 | 163 | } |
| 146 | 164 | if ( ! empty( $field['fieldOptions'] ) && is_array( $field['fieldOptions'] ) ) { |
| 147 | 165 | // @phpstan-ignore-next-line -- $field['fieldOptions'] is validated as array above. |
| 148 | 166 | $field_options = $field['fieldOptions']; |