| @@ -71,8 +71,10 @@ | ||
| 71 | 71 | add_action( 'gform_editor_js', array($this,'editor_script') ); |
| 72 | 72 | include SUPERADDONS_GF_REPEATER_PLUGIN_PATH."fields/repeater_field.php"; |
| 73 | 73 | include SUPERADDONS_GF_REPEATER_PLUGIN_PATH."fields/repeater_start_field.php"; |
| 74 | 74 | add_filter( 'gform_pre_validation', array( "Superaddons_GFRepeater_Field", 'remove_validation' ) ); |
| 75 | + add_filter( 'gform_admin_pre_render', array( 'Superaddons_GFRepeater_Field', 'remove_child_fields' ) ); | |
| 76 | + add_filter( 'gform_form_post_get_meta', array( 'Superaddons_GFRepeater_Field', 'remove_child_fields' ) ); | |
| 75 | 77 | add_action( 'gform_enqueue_scripts', array($this,"add_data"),10,2 ); |
| 76 | 78 | } |
| 77 | 79 | function gform_input_mask_script($script_str,$form_id,$field_id,$mask){ |
| 78 | 80 | $input_mask = get_option( "yeeaddons_gf_input_mask",array()); |
| @@ -81,11 +83,33 @@ | ||
| 81 | 83 | return $script_str; |
| 82 | 84 | } |
| 83 | 85 | function add_data($form, $is_ajax ){ |
| 84 | 86 | $input_mask = get_option( "yeeaddons_gf_input_mask",array()); |
| 85 | - wp_enqueue_script( 'gf_repeater', SUPERADDONS_GF_REPEATER_PLUGIN_URL."libs/wp_repeater.js", array('jquery',"gform_masked_input"),time()); | |
| 86 | - $check_pro = get_option( '_redmuber_item_1540'); | |
| 87 | - wp_localize_script("gf_repeater","yeeaddons_gf_repeater_data",array("input_mask"=>($input_mask),"pro"=>$check_pro)); | |
| 87 | + if ( isset( $form['fields'] ) && is_array( $form['fields'] ) ) { | |
| 88 | + foreach ( $form['fields'] as $field ) { | |
| 89 | + // 1. Các trường Text / Field thường tick "Input Mask" | |
| 90 | + if ( ! empty( $field->inputMask ) && ! empty( $field->inputMaskValue ) ) { | |
| 91 | + $input_mask["input_" . $form['id'] . "_" . $field->id] = (string) $field->inputMaskValue; | |
| 92 | + } | |
| 93 | + // 2. Các trường Phone | |
| 94 | + if ( isset( $field->type ) && $field->type === 'phone' ) { | |
| 95 | + $phone_format = method_exists( $field, 'get_phone_format' ) ? $field->get_phone_format() : array(); | |
| 96 | + $mask = isset( $phone_format['mask'] ) ? $phone_format['mask'] : ''; | |
| 97 | + if ( empty( $mask ) && ( ! isset( $field->phoneFormat ) || $field->phoneFormat === 'standard' || empty( $field->phoneFormat ) ) ) { | |
| 98 | + $mask = '(999) 999-9999'; | |
| 99 | + } | |
| 100 | + if ( ! empty( $mask ) ) { | |
| 101 | + $input_mask["input_" . $form['id'] . "_" . $field->id] = (string) $mask; | |
| 102 | + } | |
| 103 | + } | |
| 104 | + } | |
| 105 | + } | |
| 106 | + if ( ! wp_script_is( 'gform_masked_input', 'registered' ) ) { | |
| 107 | + wp_register_script( 'gform_masked_input', SUPERADDONS_GF_REPEATER_PLUGIN_URL . 'libs/jquery.maskedinput.min.js', array( 'jquery' ), '1.3.1', true ); | |
| 108 | + } | |
| 109 | + wp_enqueue_script( 'gf_repeater', SUPERADDONS_GF_REPEATER_PLUGIN_URL . "libs/wp_repeater.js", array( 'jquery', 'gform_masked_input' ), time() ); | |
| 110 | + $check_pro = get_option( '_redmuber_item_1540' ); | |
| 111 | + wp_localize_script( "gf_repeater", "yeeaddons_gf_repeater_data", array( "input_mask" => ( $input_mask ), "pro" => $check_pro ) ); | |
| 88 | 112 | } |
| 89 | 113 | public function styles() { |
| 90 | 114 | $styles = array( |
| 91 | 115 | array( |