PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.1
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 -83 6.265.1 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
@@ -48,10 +46,8 @@
48 46 /**
49 47 * Registers sub fields.
50 48 *
51 49 * @param array $sub_fields Sub fields. Accepts array or array or array of string.
52 - *
53 - * @return void
54 50 */
55 51 protected function register_sub_fields( array $sub_fields ) {
56 52 $defaults = $this->get_default_sub_field();
57 53
@@ -75,24 +71,8 @@
75 71 ),
76 72 $defaults
77 73 );
78 74 }
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 75 }
96 76 }
97 77
98 78 /**
@@ -130,10 +110,9 @@
130 110 continue;
131 111 }
132 112
133 113 foreach ( $sub_field['options'] as $option ) {
134 - if ( 'default_value' === $option ) {
135 - // We parse default value from field column.
114 + if ( 'default_value' === $option ) { // We parse default value from field column.
136 115 continue;
137 116 }
138 117
139 118 if ( is_string( $option ) ) {
@@ -151,12 +130,9 @@
151 130 * Include the settings for placeholder, default value, and sub labels for each
152 131 * of the individual field labels.
153 132 *
154 133 * @since 4.0
155 - *
156 134 * @param array $args Includes 'field', 'display'.
157 - *
158 - * @return void
159 135 */
160 136 public function show_after_default( $args ) {
161 137 $field = (array) $args['field'];
162 138 $default_value = $this->get_default_value();
@@ -164,9 +140,8 @@
164 140
165 141 foreach ( $this->sub_fields as $name => $sub_field ) {
166 142 $sub_field['name'] = $name;
167 143 $wrapper_classes = 'frm_grid_container frm_sub_field_options frm_sub_field_options-' . $sub_field['name'];
168 -
169 144 if ( ! isset( $processed_sub_fields[ $name ] ) ) {
170 145 // Options for this subfield should be hidden.
171 146 $wrapper_classes .= ' frm_hidden';
172 147 }
@@ -201,10 +176,9 @@
201 176
202 177 return $default_value;
203 178 }
204 179
205 - // We store default value as JSON string in db.
206 - return json_decode( $default_value, true );
180 + return json_decode( $default_value, true ); // We store default value as JSON string in db.
207 181 }
208 182
209 183 /**
210 184 * Gets labels for built-in options of fields or sub fields.
@@ -227,10 +201,9 @@
227 201 protected function field_settings_for_type() {
228 202 $settings = array(
229 203 'description' => false,
230 204 'default' => false,
231 - // Don't use the regular placeholder option.
232 - 'clear_on_focus' => false,
205 + 'clear_on_focus' => false, // Don't use the regular placeholder option.
233 206 'logic' => true,
234 207 'visibility' => true,
235 208 );
236 209
@@ -240,10 +213,8 @@
240 213 /**
241 214 * Shows field on the form builder.
242 215 *
243 216 * @param string $name Field name.
244 - *
245 - * @return void
246 217 */
247 218 public function show_on_form_builder( $name = '' ) {
248 219 $field = FrmFieldsHelper::setup_edit_vars( $this->field );
249 220
@@ -269,9 +240,8 @@
269 240 * Shows field in the frontend.
270 241 *
271 242 * @param array $args Arguments.
272 243 * @param array $shortcode_atts Shortcode attributes.
273 - *
274 244 * @return string
275 245 */
276 246 public function front_field_input( $args, $shortcode_atts ) {
277 247 $field = (array) $this->field;
@@ -276,9 +246,8 @@
276 246 public function front_field_input( $args, $shortcode_atts ) {
277 247 $field = (array) $this->field;
278 248
279 249 $field['default_value'] = $this->get_default_value();
280 -
281 250 if ( empty( $field['value'] ) ) {
282 251 $field['value'] = $field['default_value'];
283 252 }
284 253
@@ -304,10 +273,8 @@
304 273 * @type array $shortcode_atts Shortcode attributes.
305 274 * @type array $errors Field errors.
306 275 * @type bool $remove_names Remove name attribute or not.
307 276 * }
308 - *
309 - * @return void
310 277 */
311 278 protected function load_field_output( $args ) {
312 279 if ( empty( $args['field'] ) ) {
313 280 return;
@@ -340,10 +307,8 @@
340 307 * @type array $shortcode_atts Shortcode attributes.
341 308 * @type array $errors Field errors.
342 309 * @type bool $remove_names Remove name attribute or not.
343 310 * }
344 - *
345 - * @return void
346 311 */
347 312 protected function process_args_for_field_output( &$args ) {
348 313 $args['field'] = (array) $args['field'];
349 314
@@ -369,10 +334,8 @@
369 334 /**
370 335 * Prints sub field input atts.
371 336 *
372 337 * @param array $args Arguments. Includes `field`, `sub_field`.
373 - *
374 - * @return void
375 338 */
376 339 protected function print_input_atts( $args ) {
377 340 $field = $args['field'];
378 341 $sub_field = $args['sub_field'];
@@ -379,9 +342,8 @@
379 342
380 343 // Placeholder.
381 344 if ( in_array( 'placeholder', $sub_field['options'], true ) ) {
382 345 $placeholders = FrmField::get_option( $field, 'placeholder' );
383 -
384 346 if ( ! empty( $placeholders[ $sub_field['name'] ] ) ) {
385 347 $field['placeholder'] = $placeholders[ $sub_field['name'] ];
386 348 }
387 349 }
@@ -386,10 +348,9 @@
386 348 }
387 349 }
388 350
389 351 // Add optional class.
390 - $classes = $sub_field['classes'] ?? '';
391 -
352 + $classes = isset( $sub_field['classes'] ) ? $sub_field['classes'] : '';
392 353 if ( is_array( $classes ) ) {
393 354 $classes = implode( ' ', $classes );
394 355 }
395 356
@@ -400,14 +361,10 @@
400 361 if ( $classes ) {
401 362 $field['input_class'] = esc_attr( $classes );
402 363 }
403 364
404 - // Fake it to avoid printing frm-val attribute.
405 - $field['default_value'] = '';
365 + $field['default_value'] = ''; // fake it to avoid printing frm-val attribute.
406 366
407 - if ( ! empty( $sub_field['name'] ) ) {
408 - $field['subfield_name'] = $sub_field['name'];
409 - }
410 367 do_action( 'frm_field_input_html', $field );
411 368
412 369 // Print custom attributes.
413 370 if ( ! empty( $sub_field['atts'] ) && is_array( $sub_field['atts'] ) ) {
@@ -420,13 +377,12 @@
420 377 /**
421 378 * Validate field.
422 379 *
423 380 * @param array $args Arguments. Includes `errors`, `value`.
424 - *
425 381 * @return array Errors array.
426 382 */
427 383 public function validate( $args ) {
428 - $errors = $args['errors'] ?? array();
384 + $errors = isset( $args['errors'] ) ? $args['errors'] : array();
429 385
430 386 if ( ! $this->field->required ) {
431 387 return $errors;
432 388 }
@@ -460,13 +416,12 @@
460 416 * @return array
461 417 */
462 418 public function get_export_headings() {
463 419 $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'];
420 + $field_id = isset( $this->field->id ) ? $this->field->id : $this->field['id'];
421 + $field_name = isset( $this->field->name ) ? $this->field->name : $this->field['name'];
422 + $field_key = isset( $this->field->field_key ) ? $this->field->field_key : $this->field['field_key'];
467 423 $sub_fields = $this->get_processed_sub_fields();
468 -
469 424 foreach ( $sub_fields as $name => $sub_field ) {
470 425 $headings[ $field_id . '_' . $name ] = $field_name . ' (' . $field_key . ') - ' . $sub_field['label'];
471 426 }
472 427
@@ -473,8 +428,9 @@
473 428 return $headings;
474 429 }
475 430
476 431 /**
432 + *
477 433 * Get a list of all field settings that should be translated
478 434 * on a multilingual site.
479 435 *
480 436 * @since 3.06.01
@@ -511,35 +467,6 @@
511 467 return array(
512 468 'class' => 'frm_combo_inputs_container',
513 469 'id' => 'frm_combo_inputs_container_' . $this->field_id,
514 470 );
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 471 }
545 472 }