PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/helpers/FrmFieldGridHelper.php +42 -21 6.27 → trunk View file →
@@ -35,14 +35,14 @@
35 35 */
36 36 private $is_frm_first;
37 37
38 38 /**
39 - * @var stdClass
39 + * @var stdClass|null
40 40 */
41 41 private $field;
42 42
43 43 /**
44 - * @var FrmFieldGridHelper
44 + * @var FrmFieldGridHelper|null
45 45 */
46 46 private $section_helper;
47 47
48 48 /**
@@ -77,9 +77,9 @@
77 77 */
78 78 public function set_field( $field ) {
79 79 $this->field = $field;
80 80
81 - if ( ! empty( $this->section_helper ) && 'end_divider' !== $field->type ) {
81 + if ( $this->section_helper && 'end_divider' !== $field->type ) {
82 82 $this->section_helper->set_field( $field );
83 83 return;
84 84 }
85 85
@@ -92,13 +92,15 @@
92 92 $this->field_layout_class = $this->get_field_layout_class();
93 93 $this->active_field_size = self::get_size_of_class( $this->field_layout_class );
94 94 }
95 95
96 - if ( 'divider' === $field->type && empty( $this->nested ) ) {
97 - $this->section_size = $this->active_field_size;
98 - $this->active_field_size = 0;
99 - $this->section_helper = new self( true );
96 + if ( 'divider' !== $field->type || $this->nested ) {
97 + return;
100 98 }
99 +
100 + $this->section_size = $this->active_field_size;
101 + $this->active_field_size = 0;
102 + $this->section_helper = new self( true );
101 103 }
102 104
103 105 /**
104 106 * @return void
@@ -103,9 +105,9 @@
103 105 /**
104 106 * @return void
105 107 */
106 108 private function maybe_close_section_helper() {
107 - if ( empty( $this->section_helper ) ) {
109 + if ( ! $this->section_helper ) {
108 110 return;
109 111 }
110 112 $this->section_helper->force_close_field_wrapper();
111 113 $this->section_helper = null;
@@ -122,11 +124,10 @@
122 124 }
123 125
124 126 $split = explode( ' ', $field['classes'] );
125 127 $this->is_frm_first = in_array( 'frm_first', $split, true );
126 - $classes = self::get_grid_classes();
127 128
128 - foreach ( $classes as $class ) {
129 + foreach ( self::get_grid_classes() as $class ) {
129 130 if ( in_array( $class, $split, true ) ) {
130 131 return $class;
131 132 }
132 133 }
@@ -145,9 +146,9 @@
145 146 if ( false === $this->parent_li && 'end_divider' !== $this->field->type ) {
146 147 $this->begin_field_wrapper();
147 148 }
148 149
149 - if ( ! empty( $this->section_helper ) && $this->section_is_open ) {
150 + if ( $this->section_helper && $this->section_is_open ) {
150 151 $this->section_helper->maybe_begin_field_wrapper();
151 152 }
152 153 }
153 154
@@ -154,12 +155,25 @@
154 155 /**
155 156 * @return bool
156 157 */
157 158 private function should_first_close_the_active_field_wrapper() {
158 - if ( false === $this->parent_li || ! empty( $this->section_helper ) ) {
159 + if ( false === $this->parent_li ) {
159 160 return false;
160 161 }
161 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 +
162 176 if ( 'end_divider' === $this->field->type ) {
163 177 return false;
164 178 }
165 179
@@ -212,9 +226,9 @@
212 226 /**
213 227 * @return void
214 228 */
215 229 public function sync_list_size() {
216 - if ( empty( $this->field ) ) {
230 + if ( ! $this->field ) {
217 231 return;
218 232 }
219 233
220 234 if ( 'divider' === $this->field->type ) {
@@ -220,9 +234,9 @@
220 234 if ( 'divider' === $this->field->type ) {
221 235 $this->section_is_open = true;
222 236 }
223 237
224 - if ( ! empty( $this->section_helper ) ) {
238 + if ( $this->section_helper ) {
225 239 $this->section_helper->sync_list_size();
226 240
227 241 if ( 'end_divider' === $this->field->type ) {
228 242 $this->maybe_close_section_helper();
@@ -230,15 +244,17 @@
230 244
231 245 return;
232 246 }
233 247
234 - if ( false !== $this->parent_li ) {
235 - ++$this->current_field_count;
236 - $this->current_list_size += $this->active_field_size;
248 + if ( false === $this->parent_li ) {
249 + return;
250 + }
237 251
238 - if ( 12 === $this->current_list_size ) {
239 - $this->close_field_wrapper();
240 - }
252 + ++$this->current_field_count;
253 + $this->current_list_size += $this->active_field_size;
254 +
255 + if ( 12 === $this->current_list_size ) {
256 + $this->close_field_wrapper();
241 257 }
242 258 }
243 259
244 260 /**
@@ -256,9 +272,14 @@
256 272 /**
257 273 * @return void
258 274 */
259 275 private function close_field_wrapper() {
260 - $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 +
261 282 echo '</ul></li>';
262 283 $this->parent_li = false;
263 284 $this->current_list_size = 0;
264 285 $this->current_field_count = 0;