public function get_field_input($form, $value = '', $entry = null)
 {
     if (is_admin()) {
         return '';
     } else {
         $form_id = $form['id'];
         $is_entry_detail = $this->is_entry_detail();
         $is_form_editor = $this->is_form_editor();
         $id = (int) $this->id;
         $field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
         $tabindex = $this->get_tabindex();
         $repeater_id = $this->repeaterId;
         $repeater_parem = $this->inputName;
         $repeater_required = $this->repeaterRequiredChildren;
         $repeater_children = $this->repeaterChildren;
         $repeater_start = apply_filters('gf_repeater_start', $this->start, $form, $this);
         $repeater_min = apply_filters('gf_repeater_min', $this->min, $form, $this);
         $repeater_max = apply_filters('gf_repeater_max', $this->max, $form, $this);
         $repeater_animations = apply_filters('gf_repeater_animations', $this->animations, $form, $this);
         if (!empty($repeater_parem)) {
             $repeater_parem_value = GFFormsModel::get_parameter_value($repeater_parem, $value, $this);
             if (!empty($repeater_parem_value)) {
                 $repeater_start = $repeater_parem_value;
             }
         }
         if (!empty($repeater_children)) {
             $repeater_children_info = array();
             $repeater_parems = GF_Field_Repeater::get_children_parem_values($form, $repeater_children);
             foreach ($repeater_children as $repeater_child) {
                 $repeater_children_info[$repeater_child] = array();
                 $repeater_child_field_index = GF_Field_Repeater::get_field_index($form, 'id', $repeater_child);
                 if (!empty($repeater_required)) {
                     if (in_array($repeater_child, $repeater_required)) {
                         $repeater_children_info[$repeater_child]['required'] = true;
                     }
                 }
                 if (!empty($repeater_parems)) {
                     if (array_key_exists($repeater_child, $repeater_parems)) {
                         $repeater_children_info[$repeater_child]['prePopulate'] = $repeater_parems[$repeater_child];
                     }
                 }
                 if ($repeater_child_field_index !== false) {
                     $repeater_child_field = $form['fields'][$repeater_child_field_index];
                     if ($repeater_child_field['inputMask']) {
                         $repeater_children_info[$repeater_child]['inputMask'] = $repeater_child_field['inputMaskValue'];
                     } elseif ($repeater_child_field['type'] == 'phone' && ($repeater_child_field['phoneFormat'] = 'standard')) {
                         $repeater_children_info[$repeater_child]['inputMask'] = "(999) 999-9999";
                     }
                     if ($repeater_child_field['conditionalLogic']) {
                         $repeater_children_info[$repeater_child]['conditionalLogic'] = $repeater_child_field['conditionalLogic'];
                     }
                     if ($repeater_child_field['maxLength']) {
                         $repeater_children_info[$repeater_child]['maxLength'] = $repeater_child_field['maxLength'];
                     }
                     if ($repeater_child_field['enableEnhancedUI']) {
                         $repeater_children_info[$repeater_child]['enableEnhancedUI'] = $repeater_child_field['enableEnhancedUI'];
                     }
                 }
             }
             $repeater_children = $repeater_children_info;
         }
         $value = array();
         $value['formId'] = $form_id;
         if (!empty($repeater_start)) {
             $value['start'] = $repeater_start;
         }
         if (!empty($repeater_min)) {
             $value['min'] = $repeater_min;
         }
         if (!empty($repeater_max)) {
             $value['max'] = $repeater_max;
         }
         if (!empty($repeater_children)) {
             $value['children'] = $repeater_children;
         }
         $value = json_encode($value);
         if (!empty($repeater_animations)) {
             $animation_script = "var animations={" . $repeater_animations . "};jQuery.extend(true,gfRepeater_repeaters[" . $form_id . "][" . $repeater_id . "].settings.animations,animations);";
             GFFormDisplay::add_init_script($form_id, 'repeater_animations', GFFormDisplay::ON_PAGE_RENDER, $animation_script);
         }
         return sprintf("<input name='input_%d' id='%s' type='hidden' class='gform_repeater' value='%s' %s />", $id, $field_id, $value, $tabindex);
     }
 }
Example #2
0
 public function get_field_input($form, $value = '', $entry = null)
 {
     if (is_admin()) {
         return '';
     } else {
         $form_id = $form['id'];
         $is_entry_detail = $this->is_entry_detail();
         $is_form_editor = $this->is_form_editor();
         $id = (int) $this->id;
         $field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
         $tabindex = $this->get_tabindex();
         $repeater_parem = $this->inputName;
         $repeater_start = $this->start;
         $repeater_min = $this->min;
         $repeater_max = $this->max;
         $repeater_required = $this->repeaterRequiredChildren;
         $repeater_children = $this->repeaterChildren;
         if (!empty($repeater_parem)) {
             $repeater_parem_value = GFFormsModel::get_parameter_value($repeater_parem, $value, $this);
             if (!empty($repeater_parem_value)) {
                 $repeater_start = $repeater_parem_value;
             }
         }
         if (!empty($repeater_children)) {
             $repeater_children_info = array();
             $repeater_parems = GF_Field_Repeater::get_children_parem_values($form, $repeater_children);
             foreach ($repeater_children as $repeater_child) {
                 $repeater_children_info[$repeater_child] = array();
                 $repeater_child_field_index = GF_Field_Repeater::get_field_index($form, 'id', $repeater_child);
                 if (!empty($repeater_required)) {
                     if (in_array($repeater_child, $repeater_required)) {
                         $repeater_children_info[$repeater_child]['required'] = true;
                     }
                 }
                 if (!empty($repeater_parems)) {
                     if (array_key_exists($repeater_child, $repeater_parems)) {
                         $repeater_children_info[$repeater_child]['prePopulate'] = $repeater_parems[$repeater_child];
                     }
                 }
                 if ($repeater_child_field_index !== false) {
                     if ($form['fields'][$repeater_child_field_index]['inputMask']) {
                         $repeater_children_info[$repeater_child]['inputMask'] = $form['fields'][$repeater_child_field_index]['inputMaskValue'];
                     } elseif ($form['fields'][$repeater_child_field_index]['type'] == 'phone' && ($form['fields'][$repeater_child_field_index]['phoneFormat'] = 'standard')) {
                         $repeater_children_info[$repeater_child]['inputMask'] = "(999) 999-9999";
                     }
                     if ($form['fields'][$repeater_child_field_index]['conditionalLogic']) {
                         $repeater_children_info[$repeater_child]['conditionalLogic'] = $form['fields'][$repeater_child_field_index]['conditionalLogic'];
                     }
                 }
             }
             $repeater_children = $repeater_children_info;
         }
         if (empty($value)) {
             $value['formId'] = $form_id;
             if (!empty($repeater_start)) {
                 $value['start'] = $repeater_start;
             }
             if (!empty($repeater_min)) {
                 $value['min'] = $repeater_min;
             }
             if (!empty($repeater_max)) {
                 $value['max'] = $repeater_max;
             }
             if (!empty($repeater_children)) {
                 $value['children'] = $repeater_children;
             }
             $value = json_encode($value);
         }
         return sprintf("<input name='input_%d' id='%s' type='hidden' class='gform_repeater' value='%s' %s />", $id, $field_id, $value, $tabindex);
     }
 }