| @@ -124,11 +124,10 @@ | ||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $split = explode( ' ', $field['classes'] ); |
| 127 | 127 | $this->is_frm_first = in_array( 'frm_first', $split, true ); |
| 128 | - $classes = self::get_grid_classes(); | |
| 129 | 128 | |
| 130 | - foreach ( $classes as $class ) { | |
| 129 | + foreach ( self::get_grid_classes() as $class ) { | |
| 131 | 130 | if ( in_array( $class, $split, true ) ) { |
| 132 | 131 | return $class; |
| 133 | 132 | } |
| 134 | 133 | } |
| @@ -156,12 +155,25 @@ | ||
| 156 | 155 | /** |
| 157 | 156 | * @return bool |
| 158 | 157 | */ |
| 159 | 158 | private function should_first_close_the_active_field_wrapper() { |
| 160 | - if ( false === $this->parent_li || $this->section_helper ) { | |
| 159 | + if ( false === $this->parent_li ) { | |
| 161 | 160 | return false; |
| 162 | 161 | } |
| 163 | 162 | |
| 163 | + /** | |
| 164 | + * Fields that sit inside an open section are wrapped by that section's own helper, so the | |
| 165 | + * row here is not theirs to close. set_field() opens the section helper for the section | |
| 166 | + * field itself, one step ahead of this check, and section_is_open is not set until | |
| 167 | + * sync_list_size() runs afterwards. Testing both is what keeps the section field subject to | |
| 168 | + * the width check below rather than being treated as though it were already inside itself. | |
| 169 | + * | |
| 170 | + * @see https://github.com/Strategy11/formidable-pro/issues/3820 | |
| 171 | + */ | |
| 172 | + if ( $this->section_helper && $this->section_is_open ) { | |
| 173 | + return false; | |
| 174 | + } | |
| 175 | + | |
| 164 | 176 | if ( 'end_divider' === $this->field->type ) { |
| 165 | 177 | return false; |
| 166 | 178 | } |
| 167 | 179 | |
| @@ -260,9 +272,14 @@ | ||
| 260 | 272 | /** |
| 261 | 273 | * @return void |
| 262 | 274 | */ |
| 263 | 275 | private function close_field_wrapper() { |
| 264 | - $this->maybe_close_section_helper(); | |
| 276 | + // Only an open section has a nested wrapper to close. A section helper that set_field() has | |
| 277 | + // just created belongs to the section about to start, so closing this row must leave it alone. | |
| 278 | + if ( $this->section_is_open ) { | |
| 279 | + $this->maybe_close_section_helper(); | |
| 280 | + } | |
| 281 | + | |
| 265 | 282 | echo '</ul></li>'; |
| 266 | 283 | $this->parent_li = false; |
| 267 | 284 | $this->current_list_size = 0; |
| 268 | 285 | $this->current_field_count = 0; |