PluginProbe
Repeater Fields for Gravity Forms / 2.0.5
Repeater Fields for Gravity Forms v2.0.5
3.2.0 3.1.1 3.1.0 3.0.4 3.0.3 3.0.2 3.0.1 3.0.0 2.5.1 2.5.0 2.4.6 trunk 2.0.5 2.0.9 2.1.0 2.3.2 2.3.7 2.4.1 2.4.3 2.4.4 2.4.5
repeater-for-gravity-forms / fields / repeater_start_field.php

repeater_start_field.php in Repeater Fields for Gravity Forms 2.0.5, at fields/repeater_start_field.php

194 lines 6.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // If Gravity Forms isn't loaded, bail.
3 if ( ! class_exists( 'GFForms' ) ) {
4 die();
5 }
6 /**
7 * Class GF_Field_Phone
8 *
9 * Handles the behavior of Phone fields.
10 *
11 * @since Unknown
12 */
13 class Superaddons_GFRepeater_Start_Field extends GF_Field {
14 /**
15 * Defines the field type.
16 *
17 * @since Unknown
18 * @access public
19 *
20 * @var string The field type.
21 */
22 public $type = 'repeater_start';
23 /**
24 * Defines the field title to be used in the form editor.
25 *
26 * @since Unknown
27 * @access public
28 *
29 * @used-by GFCommon::get_field_type_title()
30 *
31 * @return string The field title. Translatable and escaped.
32 */
33 public function get_form_editor_field_title() {
34 return esc_attr__('Repeater Start', 'gravityforms-repeater' );
35 }
36 public function get_form_editor_button() {
37 return array(
38 'group' => 'advanced_fields',
39 'text' => $this->get_form_editor_field_title()
40 );
41 }
42 /**
43 * Defines the field settings available within the field editor.
44 *
45 * @since Unknown
46 * @access public
47 *
48 * @return array The field settings available for the field.
49 */
50 function get_form_editor_field_settings() {
51 return array(
52 'prepopulate_field_setting',
53 'label_setting',
54 'field_field_repeater_title_setting',
55 'css_class_setting',
56 );
57 }
58 /**
59 * Defines if conditional logic is supported in this field type.
60 *
61 * @since Unknown
62 * @access public
63 *
64 * @used-by GFFormDetail::inline_scripts()
65 * @used-by GFFormSettings::output_field_scripts()
66 *
67 * @return bool true
68 */
69 public function is_conditional_logic_supported() {
70 return true;
71 }
72 /**
73 * Returns the field input.
74 *
75 * @since Unknown
76 * @access public
77 *
78 * @used-by GFCommon::get_field_input()
79 * @uses GF_Field::is_entry_detail()
80 * @uses GF_Field::is_form_editor()
81 * @uses GF_Field_Phone::$failed_validation
82 * @uses GF_Field_Phone::get_phone_format()
83 * @uses GFFormsModel::is_html5_enabled()
84 * @uses GF_Field::get_field_placeholder_attribute()
85 * @uses GF_Field_Phone::$isRequired
86 * @uses GF_Field::get_tabindex()
87 *
88 * @param array $form The Form Object.
89 * @param string $value The value of the input. Defaults to empty string.
90 * @param null|array $entry The Entry Object. Defaults to null.
91 *
92 * @return string The HTML markup for the field.
93 */
94 public function get_field_input( $form, $value = '', $entry = null ) {
95 if ( is_array( $value ) ) {
96 $value = '';
97 }
98 $is_entry_detail = $this->is_entry_detail();
99 $is_form_editor = $this->is_form_editor();
100 $form_id = $form['id'];
101 $id = intval( $this->id );
102 $field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_$id" : 'input_' . $form_id . "_$id";
103 $size = $this->size;
104 $disabled_text = $is_form_editor ? "disabled='disabled'" : '';
105 $class_suffix = $is_entry_detail ? '_admin' : '';
106 $class = $size . $class_suffix. " hidden";
107 $class = esc_attr( $class );
108 $repeater_title = $this->repeater_title;
109 $html = '<div class="wpforms-field-repeater-start">
110 <textarea class="repeater-field-header-data hidden"><div class="repeater-field-header">
111 <div class="repeater-field-header-title">'.$repeater_title." ";
112 $html .= '<span class="repeater-field-header-count">1</span>';
113 $html .= '</div>
114 <div class="repeater-field-header-acctions">
115 <ul>
116 <li><i class="repeater-icon icon-down-open repeater-field-header-acctions-toogle" aria-hidden="true"></i></li>
117 <li><i class="repeater-icon icon-cancel-1 repeater-field-header-acctions-remove" aria-hidden="true"></i></li>
118 </ul>
119 </div>
120 </div></textarea>
121 </div>';
122 if (is_admin()) {
123 $html = '<hr>Begin Repeater<hr>';
124 return sprintf( "<div class='ginput_container1'>%s</div>", $html);
125 }else{
126 return sprintf( "<div class='ginput_container ginput_container_text'> %s </div>", $html);
127 }
128 }
129 /**
130 * Gets the value of the submitted field.
131 *
132 * @since Unknown
133 * @access public
134 *
135 * @used-by GFFormsModel::get_field_value()
136 * @uses GF_Field::get_value_submission()
137 * @uses GF_Field_Phone::sanitize_entry_value()
138 *
139 * @param array $field_values The dynamic population parameter names with their corresponding values to be populated.
140 * @param bool $get_from_post_global_var Whether to get the value from the $_POST array as opposed to $field_values. Defaults to true.
141 *
142 * @return array|string
143 */
144 public function get_value_submission( $field_values, $get_from_post_global_var = true ) {
145 return false;
146 }
147 /**
148 * Sanitizes the entry value.
149 *
150 * @since Unknown
151 * @access public
152 *
153 * @used-by GF_Field_Phone::get_value_save_entry()
154 * @used-by GF_Field_Phone::get_value_submission()
155 *
156 * @param string $value The value to be sanitized.
157 * @param int $form_id The form ID of the submitted item.
158 *
159 * @return string The sanitized value.
160 */
161 public function sanitize_entry_value( $value, $form_id ) {
162 return false;
163 }
164 /**
165 * Gets the field value when an entry is being saved.
166 *
167 * @since Unknown
168 * @access public
169 *
170 * @used-by GFFormsModel::prepare_value()
171 * @uses GF_Field_Phone::sanitize_entry_value()
172 * @uses GF_Field_Phone::$phoneFormat
173 *
174 * @param string $value The input value.
175 * @param array $form The Form Object.
176 * @param string $input_name The input name.
177 * @param int $lead_id The Entry ID.
178 * @param array $lead The Entry Object.
179 *
180 * @return string The field value.
181 */
182 public function get_value_save_entry( $value, $form, $input_name, $lead_id, $lead ) {
183 return false;
184 }
185 public function get_value_entry_list( $value, $entry, $field_id, $columns, $form ) {
186 return false;
187 }
188 public function get_value_entry_detail( $value, $currency = '', $use_text = false, $format = 'html', $media = 'screen' ) {
189 return false;
190 }
191 }
192 // Register the phone field with the field framework.
193 GF_Fields::register( new Superaddons_GFRepeater_Start_Field() );
194