File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed
Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010This is an alpha version! The changes listed here are not final.
1111
1212### Fixed
13+ - Forms: Ensure fields that skip rendering (like empty options fields) do not trigger validation or show value in form submission response.
1314- Forms: Fix 404 error when a user submits an invalid form with JavaScript disabled.
1415
1516## [ 0.39.0] - 2025-02-24
Original file line number Diff line number Diff line change @@ -205,13 +205,14 @@ public function is_error() {
205205 * Validates the form input
206206 */
207207 public function validate () {
208+ $ field_type = $ this ->maybe_override_type ();
209+
208210 // If it's not required, there's nothing to validate
209- if ( ! $ this ->get_attribute ( 'required ' ) ) {
211+ if ( ! $ this ->get_attribute ( 'required ' ) || ! $ this -> is_field_renderable ( $ field_type ) ) {
210212 return ;
211213 }
212214
213215 $ field_id = $ this ->get_attribute ( 'id ' );
214- $ field_type = $ this ->maybe_override_type ();
215216 $ field_label = $ this ->get_attribute ( 'label ' );
216217
217218 if ( isset ( $ _POST [ $ field_id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- no site changes.
Original file line number Diff line number Diff line change @@ -1161,6 +1161,11 @@ public function process_submission() {
11611161 // For all fields, grab label and value
11621162 foreach ( $ field_ids ['all ' ] as $ field_id ) {
11631163 $ field = $ this ->fields [ $ field_id ];
1164+
1165+ if ( ! $ field ->is_field_renderable ( $ field ->get_attribute ( 'type ' ) ) ) {
1166+ continue ;
1167+ }
1168+
11641169 $ label = $ i . '_ ' . $ field ->get_attribute ( 'label ' );
11651170 $ value = $ field ->value ;
11661171
@@ -1172,6 +1177,11 @@ public function process_submission() {
11721177 // Extra fields have their prefix starting from count( $all_values ) + 1
11731178 foreach ( $ field_ids ['extra ' ] as $ field_id ) {
11741179 $ field = $ this ->fields [ $ field_id ];
1180+
1181+ if ( ! $ field ->is_field_renderable ( $ field ->get_attribute ( 'type ' ) ) ) {
1182+ continue ;
1183+ }
1184+
11751185 $ label = $ i . '_ ' . $ field ->get_attribute ( 'label ' );
11761186 $ value = $ field ->value ;
11771187
You can’t perform that action at this time.
0 commit comments