PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.8
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.8
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/controllers/FrmFieldsController.php +55 -20 6.46.8 View file →
@@ -72,9 +72,9 @@
72 72
73 73 /**
74 74 * Set up and create a new field
75 75 *
76 - * @param string $field_type
76 + * @param string $field_type
77 77 * @param integer $form_id
78 78 *
79 79 * @return array|bool
80 80 */
@@ -79,12 +79,18 @@
79 79 * @return array|bool
80 80 */
81 81 public static function include_new_field( $field_type, $form_id ) {
82 82 $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id );
83 +
84 + // When a new field is added to the form, flag it as draft and hide it from the front-end.
85 + $field_values['field_options']['draft'] = 1;
86 +
87 + /**
88 + * @param array $field_values
89 + */
83 90 $field_values = apply_filters( 'frm_before_field_created', $field_values );
91 + $field_id = FrmField::create( $field_values );
84 92
85 - $field_id = FrmField::create( $field_values );
86 -
87 93 if ( ! $field_id ) {
88 94 return false;
89 95 }
90 96
@@ -137,10 +143,10 @@
137 143 /**
138 144 * @since 3.0
139 145 *
140 146 * @param int|array|object $field_object
141 - * @param array $values
142 - * @param int $form_id
147 + * @param array $values
148 + * @param int $form_id
143 149 */
144 150 public static function load_single_field( $field_object, $values, $form_id = 0 ) {
145 151 global $frm_vars;
146 152 $frm_vars['is_admin'] = true;
@@ -203,10 +209,11 @@
203 209 FrmField::destroy( $field_id );
204 210 wp_die();
205 211 }
206 212
207 - /* Field Options */
208 -
213 + /**
214 + * Field Options.
215 + */
209 216 public static function import_options() {
210 217 FrmAppHelper::permission_check( 'frm_edit_forms' );
211 218 check_ajax_referer( 'frm_ajax', 'nonce' );
212 219
@@ -312,9 +319,10 @@
312 319
313 320 if ( $display['clear_on_focus'] && is_array( $field['placeholder'] ) ) {
314 321 $field['placeholder'] = implode( ', ', $field['placeholder'] );
315 322 }
316 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/settings.php' );
323 +
324 + include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/settings.php';
317 325 }
318 326
319 327 /**
320 328 * Get the list of default value types that can be toggled in the builder.
@@ -388,10 +396,13 @@
388 396 $type = $type_switch[ $type ];
389 397 }
390 398
391 399 $pro_fields = FrmField::pro_field_selection();
392 - $types = array_keys( $pro_fields );
393 - if ( in_array( $type, $types ) ) {
400 + // We want to keep credit_card types as credit card types for Stripe Lite.
401 + // The credit_card key is set for backward compatibility.
402 + unset( $pro_fields['credit_card'] );
403 +
404 + if ( array_key_exists( $type, $pro_fields ) ) {
394 405 $type = 'text';
395 406 }
396 407
397 408 return $type;
@@ -397,9 +408,9 @@
397 408 return $type;
398 409 }
399 410
400 411 /**
401 - * @param array $settings
412 + * @param array $settings
402 413 * @param object $field_info
403 414 *
404 415 * @return array
405 416 */
@@ -493,9 +504,9 @@
493 504 self::add_html_cols( $field, $add_html );
494 505 }
495 506
496 507 private static function add_html_cols( $field, array &$add_html ) {
497 - if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) {
508 + if ( ! in_array( $field['type'], array( 'textarea', 'rte' ), true ) ) {
498 509 return;
499 510 }
500 511
501 512 // Convert to cols for textareas.
@@ -610,14 +621,31 @@
610 621 if ( empty( $placeholder ) ) {
611 622 $placeholder = self::get_default_value_from_name( $field );
612 623 }
613 624
625 + $use_placeholder = $placeholder;
626 + $autocomplete = FrmField::get_option( $field, 'autocom' );
627 +
628 + if ( $autocomplete ) {
629 + $use_chosen = ! is_callable( 'FrmProAppHelper::use_chosen_js' ) || FrmProAppHelper::use_chosen_js();
630 + if ( $use_chosen ) {
631 + $use_placeholder = '';
632 + }
633 + }
634 +
614 635 if ( $placeholder !== '' ) {
615 - ?>
616 - <option value="">
617 - <?php echo esc_html( FrmField::get_option( $field, 'autocom' ) ? '' : $placeholder ); ?>
618 - </option>
619 - <?php
636 + $placeholder_attributes = array(
637 + 'class' => 'frm-select-placeholder',
638 + 'value' => '',
639 + 'data-placeholder' => 'true',
640 + );
641 +
642 + if ( $autocomplete && empty( $use_chosen ) ) {
643 + // This is required for Slim Select.
644 + $placeholder_attributes['data-placeholder'] = 'true';
645 + }
646 +
647 + FrmHtmlHelper::echo_dropdown_option( $use_placeholder, false, $placeholder_attributes );
620 648 return true;
621 649 }
622 650
623 651 return false;
@@ -752,9 +780,16 @@
752 780 * @param array $field
753 781 * @param array $add_html
754 782 */
755 783 private static function maybe_add_html_required( $field, array &$add_html ) {
756 - if ( in_array( $field['type'], array( 'file', 'data', 'lookup' ), true ) ) {
784 + $excluded_field_types =
785 + FrmField::is_radio( $field ) ||
786 + FrmField::is_checkbox( $field ) ||
787 + FrmField::is_field_type( $field, 'file' ) ||
788 + FrmField::is_field_type( $field, 'nps' ) ||
789 + FrmField::is_field_type( $field, 'scale' );
790 +
791 + if ( $excluded_field_types ) {
757 792 return;
758 793 }
759 794
760 795 $include_html = FrmAppHelper::meets_min_pro_version( '3.06.01' );
@@ -900,11 +935,11 @@
900 935 /**
901 936 * @deprecated 3.0
902 937 * @codeCoverageIgnore
903 938 *
904 - * @param int $field_id
939 + * @param int $field_id
905 940 * @param array $values
906 - * @param int $form_id
941 + * @param int $form_id
907 942 *
908 943 * @return array
909 944 */
910 945 public static function include_single_field( $field_id, $values, $form_id = 0 ) {