PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.7
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.7
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/models/fields/FrmFieldCombo.php +10 -70 6.266.7 View file →
@@ -2,9 +2,8 @@
2 2 /**
3 3 * Combo field - Field contains sub fields
4 4 *
5 5 * @package Formidable
6 - *
7 6 * @since 4.11
8 7 */
9 8
10 9 if ( ! defined( 'ABSPATH' ) ) {
@@ -16,9 +15,8 @@
16 15 /**
17 16 * Does the html for this field label need to include "for"?
18 17 *
19 18 * @var bool
20 - *
21 19 * @since 3.0
22 20 */
23 21 protected $has_for_label = false;
24 22
@@ -75,24 +73,8 @@
75 73 ),
76 74 $defaults
77 75 );
78 76 }
79 - }//end foreach
80 - }
81 -
82 - /**
83 - * Set the aria-invalid attribute for subfields.
84 - *
85 - * @since 6.16.3
86 - *
87 - * @param array $shortcode_atts
88 - * @param array $args
89 - *
90 - * @return void
91 - */
92 - public function set_aria_invalid_error( &$shortcode_atts, $args ) {
93 - foreach ( $this->get_sub_fields() as $sub_field ) {
94 - $shortcode_atts[ 'aria-invalid-' . $sub_field['name'] ] = isset( $args['errors'][ 'field' . $this->field_id . '-' . $sub_field['name'] ] ) ? 'true' : 'false';
95 77 }
96 78 }
97 79
98 80 /**
@@ -130,10 +112,9 @@
130 112 continue;
131 113 }
132 114
133 115 foreach ( $sub_field['options'] as $option ) {
134 - if ( 'default_value' === $option ) {
135 - // We parse default value from field column.
116 + if ( 'default_value' === $option ) { // We parse default value from field column.
136 117 continue;
137 118 }
138 119
139 120 if ( is_string( $option ) ) {
@@ -164,9 +145,8 @@
164 145
165 146 foreach ( $this->sub_fields as $name => $sub_field ) {
166 147 $sub_field['name'] = $name;
167 148 $wrapper_classes = 'frm_grid_container frm_sub_field_options frm_sub_field_options-' . $sub_field['name'];
168 -
169 149 if ( ! isset( $processed_sub_fields[ $name ] ) ) {
170 150 // Options for this subfield should be hidden.
171 151 $wrapper_classes .= ' frm_hidden';
172 152 }
@@ -201,10 +181,9 @@
201 181
202 182 return $default_value;
203 183 }
204 184
205 - // We store default value as JSON string in db.
206 - return json_decode( $default_value, true );
185 + return json_decode( $default_value, true ); // We store default value as JSON string in db.
207 186 }
208 187
209 188 /**
210 189 * Gets labels for built-in options of fields or sub fields.
@@ -227,10 +206,9 @@
227 206 protected function field_settings_for_type() {
228 207 $settings = array(
229 208 'description' => false,
230 209 'default' => false,
231 - // Don't use the regular placeholder option.
232 - 'clear_on_focus' => false,
210 + 'clear_on_focus' => false, // Don't use the regular placeholder option.
233 211 'logic' => true,
234 212 'visibility' => true,
235 213 );
236 214
@@ -269,9 +247,8 @@
269 247 * Shows field in the frontend.
270 248 *
271 249 * @param array $args Arguments.
272 250 * @param array $shortcode_atts Shortcode attributes.
273 - *
274 251 * @return string
275 252 */
276 253 public function front_field_input( $args, $shortcode_atts ) {
277 254 $field = (array) $this->field;
@@ -276,9 +253,8 @@
276 253 public function front_field_input( $args, $shortcode_atts ) {
277 254 $field = (array) $this->field;
278 255
279 256 $field['default_value'] = $this->get_default_value();
280 -
281 257 if ( empty( $field['value'] ) ) {
282 258 $field['value'] = $field['default_value'];
283 259 }
284 260
@@ -379,9 +355,8 @@
379 355
380 356 // Placeholder.
381 357 if ( in_array( 'placeholder', $sub_field['options'], true ) ) {
382 358 $placeholders = FrmField::get_option( $field, 'placeholder' );
383 -
384 359 if ( ! empty( $placeholders[ $sub_field['name'] ] ) ) {
385 360 $field['placeholder'] = $placeholders[ $sub_field['name'] ];
386 361 }
387 362 }
@@ -386,10 +361,9 @@
386 361 }
387 362 }
388 363
389 364 // Add optional class.
390 - $classes = $sub_field['classes'] ?? '';
391 -
365 + $classes = isset( $sub_field['classes'] ) ? $sub_field['classes'] : '';
392 366 if ( is_array( $classes ) ) {
393 367 $classes = implode( ' ', $classes );
394 368 }
395 369
@@ -400,14 +374,10 @@
400 374 if ( $classes ) {
401 375 $field['input_class'] = esc_attr( $classes );
402 376 }
403 377
404 - // Fake it to avoid printing frm-val attribute.
405 - $field['default_value'] = '';
378 + $field['default_value'] = ''; // fake it to avoid printing frm-val attribute.
406 379
407 - if ( ! empty( $sub_field['name'] ) ) {
408 - $field['subfield_name'] = $sub_field['name'];
409 - }
410 380 do_action( 'frm_field_input_html', $field );
411 381
412 382 // Print custom attributes.
413 383 if ( ! empty( $sub_field['atts'] ) && is_array( $sub_field['atts'] ) ) {
@@ -420,13 +390,12 @@
420 390 /**
421 391 * Validate field.
422 392 *
423 393 * @param array $args Arguments. Includes `errors`, `value`.
424 - *
425 394 * @return array Errors array.
426 395 */
427 396 public function validate( $args ) {
428 - $errors = $args['errors'] ?? array();
397 + $errors = isset( $args['errors'] ) ? $args['errors'] : array();
429 398
430 399 if ( ! $this->field->required ) {
431 400 return $errors;
432 401 }
@@ -460,13 +429,12 @@
460 429 * @return array
461 430 */
462 431 public function get_export_headings() {
463 432 $headings = array();
464 - $field_id = $this->field->id ?? $this->field['id'];
465 - $field_name = $this->field->name ?? $this->field['name'];
466 - $field_key = $this->field->field_key ?? $this->field['field_key'];
433 + $field_id = isset( $this->field->id ) ? $this->field->id : $this->field['id'];
434 + $field_name = isset( $this->field->name ) ? $this->field->name : $this->field['name'];
435 + $field_key = isset( $this->field->field_key ) ? $this->field->field_key : $this->field['field_key'];
467 436 $sub_fields = $this->get_processed_sub_fields();
468 -
469 437 foreach ( $sub_fields as $name => $sub_field ) {
470 438 $headings[ $field_id . '_' . $name ] = $field_name . ' (' . $field_key . ') - ' . $sub_field['label'];
471 439 }
472 440
@@ -473,8 +441,9 @@
473 441 return $headings;
474 442 }
475 443
476 444 /**
445 + *
477 446 * Get a list of all field settings that should be translated
478 447 * on a multilingual site.
479 448 *
480 449 * @since 3.06.01
@@ -511,35 +480,6 @@
511 480 return array(
512 481 'class' => 'frm_combo_inputs_container',
513 482 'id' => 'frm_combo_inputs_container_' . $this->field_id,
514 483 );
515 - }
516 -
517 - /**
518 - * Gets subfield input attributes.
519 - *
520 - * @since 6.26
521 - *
522 - * @param array $sub_field Subfield data.
523 - * @param array $args Field output args. See {@see FrmFieldCombo::load_field_output()}.
524 - *
525 - * @return array
526 - */
527 - protected function get_sub_field_input_attrs( $sub_field, $args ) {
528 - $attrs = array(
529 - 'type' => $sub_field['type'],
530 - 'id' => $args['html_id'] . '_' . $sub_field['name'],
531 - 'value' => '',
532 - );
533 -
534 - if ( ! empty( $args['field']['value'][ $sub_field['name'] ] ) ) {
535 - $attrs['value'] = $args['field']['value'][ $sub_field['name'] ];
536 - $attrs['data-frmval'] = $args['field']['value'][ $sub_field['name'] ];
537 - }
538 -
539 - if ( empty( $args['remove_names'] ) ) {
540 - $attrs['name'] = $args['field_name'] . '[' . $sub_field['name'] . ']';
541 - }
542 -
543 - return $attrs;
544 484 }
545 485 }