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/controllers/FrmFieldsController.php +47 -34 6.55.1 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
@@ -759,16 +764,9 @@
759 764 * @param array $field
760 765 * @param array $add_html
761 766 */
762 767 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 ) {
768 + if ( in_array( $field['type'], array( 'file', 'data', 'lookup' ), true ) ) {
771 769 return;
772 770 }
773 771
774 772 $include_html = FrmAppHelper::meets_min_pro_version( '3.06.01' );
@@ -781,12 +779,8 @@
781 779 if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
782 780 return;
783 781 }
784 782
785 - if ( ! empty( $field['autocomplete'] ) ) {
786 - unset( $field['shortcodes']['autocomplete'] );
787 - }
788 -
789 783 foreach ( $field['shortcodes'] as $k => $v ) {
790 784 if ( 'opt' === $k ) {
791 785 continue;
792 786 }
@@ -892,9 +886,12 @@
892 886 *
893 887 * @deprecated 4.0 Moved to Pro for Other option only.
894 888 */
895 889 public static function add_option() {
896 - _deprecated_function( __METHOD__, '4.0', 'FrmProFieldsController::add_other_option' );
890 + _deprecated_function( __METHOD__, '4.0', 'FrmProFormsController::add_other_option' );
891 + if ( is_callable( 'FrmProFormsController::add_other_option' ) ) {
892 + FrmProFormsController::add_other_option();
893 + }
897 894 }
898 895
899 896 /**
900 897 * @deprecated 4.0
@@ -922,6 +919,22 @@
922 919 * @return array
923 920 */
924 921 public static function include_single_field( $field_id, $values, $form_id = 0 ) {
925 922 return FrmDeprecated::include_single_field( $field_id, $values, $form_id );
923 + }
924 +
925 + /**
926 + * @deprecated 2.3
927 + * @codeCoverageIgnore
928 + */
929 + public static function edit_option() {
930 + FrmDeprecated::deprecated( __METHOD__, '2.3' );
931 + }
932 +
933 + /**
934 + * @deprecated 2.3
935 + * @codeCoverageIgnore
936 + */
937 + public static function delete_option() {
938 + FrmDeprecated::deprecated( __METHOD__, '2.3' );
926 939 }
927 940 }