| @@ -569,18 +569,21 @@ | ||
| 569 | 569 | } |
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | /** |
| 573 | - * Prepares field placeholder. | |
| 574 | - * | |
| 575 | - * @since 5.4 This doesn't call `FrmFieldsController::get_default_value_from_name()` anymore. | |
| 576 | - * | |
| 577 | - * @param array $field Field array. | |
| 573 | + * @param array $field | |
| 578 | 574 | * @return string |
| 579 | 575 | */ |
| 580 | 576 | private static function prepare_placeholder( $field ) { |
| 581 | - $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 ); | |
| 582 | 581 | |
| 582 | + if ( $placeholder_is_blank && $is_placeholder_field && ! $is_combo_field ) { | |
| 583 | + $placeholder = self::get_default_value_from_name( $field ); | |
| 584 | + } | |
| 585 | + | |
| 583 | 586 | return $placeholder; |
| 584 | 587 | } |
| 585 | 588 | |
| 586 | 589 | /** |
| @@ -587,9 +590,8 @@ | ||
| 587 | 590 | * If the label position is "inside", |
| 588 | 591 | * get the label to use as the placeholder |
| 589 | 592 | * |
| 590 | 593 | * @since 2.05 |
| 591 | - * @since 5.4 Remove the logic code for "inside" label position. | |
| 592 | 594 | * |
| 593 | 595 | * @param array $field |
| 594 | 596 | * |
| 595 | 597 | * @return string |
| @@ -594,9 +596,19 @@ | ||
| 594 | 596 | * |
| 595 | 597 | * @return string |
| 596 | 598 | */ |
| 597 | 599 | public static function get_default_value_from_name( $field ) { |
| 598 | - 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; | |
| 599 | 611 | } |
| 600 | 612 | |
| 601 | 613 | /** |
| 602 | 614 | * Maybe add a blank placeholder option before any options |
| @@ -752,16 +764,9 @@ | ||
| 752 | 764 | * @param array $field |
| 753 | 765 | * @param array $add_html |
| 754 | 766 | */ |
| 755 | 767 | private static function maybe_add_html_required( $field, array &$add_html ) { |
| 756 | - $excluded_field_types = | |
| 757 | - FrmField::is_radio( $field ) || | |
| 758 | - FrmField::is_checkbox( $field ) || | |
| 759 | - FrmField::is_field_type( $field, 'file' ) || | |
| 760 | - FrmField::is_field_type( $field, 'nps' ) || | |
| 761 | - FrmField::is_field_type( $field, 'scale' ); | |
| 762 | - | |
| 763 | - if ( $excluded_field_types ) { | |
| 768 | + if ( in_array( $field['type'], array( 'file', 'data', 'lookup' ), true ) ) { | |
| 764 | 769 | return; |
| 765 | 770 | } |
| 766 | 771 | |
| 767 | 772 | $include_html = FrmAppHelper::meets_min_pro_version( '3.06.01' ); |
| @@ -774,12 +779,8 @@ | ||
| 774 | 779 | if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
| 775 | 780 | return; |
| 776 | 781 | } |
| 777 | 782 | |
| 778 | - if ( ! empty( $field['autocomplete'] ) ) { | |
| 779 | - unset( $field['shortcodes']['autocomplete'] ); | |
| 780 | - } | |
| 781 | - | |
| 782 | 783 | foreach ( $field['shortcodes'] as $k => $v ) { |
| 783 | 784 | if ( 'opt' === $k ) { |
| 784 | 785 | continue; |
| 785 | 786 | } |
| @@ -885,9 +886,12 @@ | ||
| 885 | 886 | * |
| 886 | 887 | * @deprecated 4.0 Moved to Pro for Other option only. |
| 887 | 888 | */ |
| 888 | 889 | public static function add_option() { |
| 889 | - _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 | + } | |
| 890 | 894 | } |
| 891 | 895 | |
| 892 | 896 | /** |
| 893 | 897 | * @deprecated 4.0 |
| @@ -915,6 +919,22 @@ | ||
| 915 | 919 | * @return array |
| 916 | 920 | */ |
| 917 | 921 | public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
| 918 | 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' ); | |
| 919 | 939 | } |
| 920 | 940 | } |