PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0.14
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0.14
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 +47 -36 6.55.0.14 View file →
@@ -79,14 +79,11 @@
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 + $field_values = apply_filters( 'frm_before_field_created', $field_values );
83 84
84 - /**
85 - * @param array $field_values
86 - */
87 - $field_values = apply_filters( 'frm_before_field_created', $field_values );
88 - $field_id = FrmField::create( $field_values );
85 + $field_id = FrmField::create( $field_values );
89 86
90 87 if ( ! $field_id ) {
91 88 return false;
92 89 }
@@ -315,10 +312,9 @@
315 312
316 313 if ( $display['clear_on_focus'] && is_array( $field['placeholder'] ) ) {
317 314 $field['placeholder'] = implode( ', ', $field['placeholder'] );
318 315 }
319 -
320 - include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/settings.php';
316 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/settings.php' );
321 317 }
322 318
323 319 /**
324 320 * Get the list of default value types that can be toggled in the builder.
@@ -392,13 +388,10 @@
392 388 $type = $type_switch[ $type ];
393 389 }
394 390
395 391 $pro_fields = FrmField::pro_field_selection();
396 - // We want to keep credit_card types as credit card types for Stripe Lite.
397 - // The credit_card key is set for backward compatibility.
398 - unset( $pro_fields['credit_card'] );
399 -
400 - if ( array_key_exists( $type, $pro_fields ) ) {
392 + $types = array_keys( $pro_fields );
393 + if ( in_array( $type, $types ) ) {
401 394 $type = 'text';
402 395 }
403 396
404 397 return $type;
@@ -500,9 +493,9 @@
500 493 self::add_html_cols( $field, $add_html );
501 494 }
502 495
503 496 private static function add_html_cols( $field, array &$add_html ) {
504 - if ( ! in_array( $field['type'], array( 'textarea', 'rte' ), true ) ) {
497 + if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) {
505 498 return;
506 499 }
507 500
508 501 // Convert to cols for textareas.
@@ -576,18 +569,21 @@
576 569 }
577 570 }
578 571
579 572 /**
580 - * Prepares field placeholder.
581 - *
582 - * @since 5.4 This doesn't call `FrmFieldsController::get_default_value_from_name()` anymore.
583 - *
584 - * @param array $field Field array.
573 + * @param array $field
585 574 * @return string
586 575 */
587 576 private static function prepare_placeholder( $field ) {
588 - $placeholder = isset( $field['placeholder'] ) ? $field['placeholder'] : '';
577 + $placeholder = isset( $field['placeholder'] ) ? $field['placeholder'] : '';
578 + $placeholder_is_blank = empty( $placeholder ) && '0' !== $placeholder;
579 + $is_placeholder_field = FrmFieldsHelper::is_placeholder_field_type( $field['type'] );
580 + $is_combo_field = in_array( $field['type'], array( 'address', 'credit_card' ), true );
589 581
582 + if ( $placeholder_is_blank && $is_placeholder_field && ! $is_combo_field ) {
583 + $placeholder = self::get_default_value_from_name( $field );
584 + }
585 +
590 586 return $placeholder;
591 587 }
592 588
593 589 /**
@@ -594,9 +590,8 @@
594 590 * If the label position is "inside",
595 591 * get the label to use as the placeholder
596 592 *
597 593 * @since 2.05
598 - * @since 5.4 Remove the logic code for "inside" label position.
599 594 *
600 595 * @param array $field
601 596 *
602 597 * @return string
@@ -601,9 +596,19 @@
601 596 *
602 597 * @return string
603 598 */
604 599 public static function get_default_value_from_name( $field ) {
605 - return '';
600 + $position = FrmField::get_option( $field, 'label' );
601 + if ( $position == 'inside' ) {
602 + $default_value = $field['name'];
603 + if ( FrmField::is_required( $field ) ) {
604 + $default_value .= ' ' . $field['required_indicator'];
605 + }
606 + } else {
607 + $default_value = '';
608 + }
609 +
610 + return $default_value;
606 611 }
607 612
608 613 /**
609 614 * Maybe add a blank placeholder option before any options
@@ -737,11 +742,9 @@
737 742
738 743 $error_body = substr( $custom_html, $start + 10, $end - $start - 10 );
739 744 $default_html = array(
740 745 '<div class="frm_error" id="frm_error_field_[key]">[error]</div>',
741 - '<div class="frm_error" role="alert" id="frm_error_field_[key]">[error]</div>',
742 746 '<div class="frm_error">[error]</div>',
743 - '<div class="frm_error" role="alert">[error]</div>',
744 747 );
745 748
746 749 if ( in_array( $error_body, $default_html, true ) ) {
747 750 return false;
@@ -759,16 +762,9 @@
759 762 * @param array $field
760 763 * @param array $add_html
761 764 */
762 765 private static function maybe_add_html_required( $field, array &$add_html ) {
763 - $excluded_field_types =
764 - FrmField::is_radio( $field ) ||
765 - FrmField::is_checkbox( $field ) ||
766 - FrmField::is_field_type( $field, 'file' ) ||
767 - FrmField::is_field_type( $field, 'nps' ) ||
768 - FrmField::is_field_type( $field, 'scale' );
769 -
770 - if ( $excluded_field_types ) {
766 + if ( in_array( $field['type'], array( 'file', 'data', 'lookup' ), true ) ) {
771 767 return;
772 768 }
773 769
774 770 $include_html = FrmAppHelper::meets_min_pro_version( '3.06.01' );
@@ -781,12 +777,8 @@
781 777 if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
782 778 return;
783 779 }
784 780
785 - if ( ! empty( $field['autocomplete'] ) ) {
786 - unset( $field['shortcodes']['autocomplete'] );
787 - }
788 -
789 781 foreach ( $field['shortcodes'] as $k => $v ) {
790 782 if ( 'opt' === $k ) {
791 783 continue;
792 784 }
@@ -892,9 +884,12 @@
892 884 *
893 885 * @deprecated 4.0 Moved to Pro for Other option only.
894 886 */
895 887 public static function add_option() {
896 - _deprecated_function( __METHOD__, '4.0', 'FrmProFieldsController::add_other_option' );
888 + _deprecated_function( __METHOD__, '4.0', 'FrmProFormsController::add_other_option' );
889 + if ( is_callable( 'FrmProFormsController::add_other_option' ) ) {
890 + FrmProFormsController::add_other_option();
891 + }
897 892 }
898 893
899 894 /**
900 895 * @deprecated 4.0
@@ -922,6 +917,22 @@
922 917 * @return array
923 918 */
924 919 public static function include_single_field( $field_id, $values, $form_id = 0 ) {
925 920 return FrmDeprecated::include_single_field( $field_id, $values, $form_id );
921 + }
922 +
923 + /**
924 + * @deprecated 2.3
925 + * @codeCoverageIgnore
926 + */
927 + public static function edit_option() {
928 + FrmDeprecated::deprecated( __METHOD__, '2.3' );
929 + }
930 +
931 + /**
932 + * @deprecated 2.3
933 + * @codeCoverageIgnore
934 + */
935 + public static function delete_option() {
936 + FrmDeprecated::deprecated( __METHOD__, '2.3' );
926 937 }
927 938 }