PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0
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/models/FrmFieldValueSelector.php +8 -66 6.265.0 View file →
@@ -4,9 +4,9 @@
4 4 }
5 5
6 6 /**
7 7 * A class for the field value selector
8 - * Used in field conditional logic, action conditional logic, Mailchimp action, etc.
8 + * Used in field conditional logic, action conditional logic, MailChimp action, etc.
9 9 *
10 10 * @since 2.03.05
11 11 */
12 12 class FrmFieldValueSelector {
@@ -25,13 +25,13 @@
25 25 */
26 26 protected $field_key = '';
27 27
28 28 /**
29 - * @var FrmProFieldSettings|null
29 + * @var null
30 30 *
31 31 * @since 2.03.05
32 32 */
33 - protected $field_settings;
33 + protected $field_settings = null;
34 34
35 35 /**
36 36 * @var array
37 37 *
@@ -67,37 +67,25 @@
67 67 */
68 68 protected $blank_option_label = '';
69 69
70 70 /**
71 - * @var object|null
71 + * @var object
72 72 *
73 73 * @since 2.03.05
74 74 */
75 - protected $db_row;
75 + protected $db_row = null;
76 76
77 77 /**
78 - * Field dropdowns will truncate at 25 characters by default.
79 - *
80 - * @var int|null
81 - *
82 - * @since 6.16.2
83 - */
84 - protected $truncate;
85 -
86 - /**
87 78 * FrmFieldValueSelector constructor
88 79 *
89 - * @param int|string $field_id Field ID.
90 - * @param array $args Arguments for configuring the value selector.
80 + * @param int|string $field_id
91 81 */
92 82 public function __construct( $field_id, $args ) {
93 83 $this->set_html_name( $args );
94 84 $this->set_value( $args );
95 85 $this->set_source( $args );
96 - $this->set_truncate( $args );
97 86
98 87 $this->field_id = (int) $field_id;
99 -
100 88 if ( $this->field_id === 0 ) {
101 89 return;
102 90 }
103 91
@@ -113,10 +101,8 @@
113 101 /**
114 102 * Set the db_row property
115 103 *
116 104 * @since 2.03.05
117 - *
118 - * @return void
119 105 */
120 106 private function set_db_row() {
121 107 $where = array(
122 108 'id' => $this->field_id,
@@ -132,10 +118,8 @@
132 118 /**
133 119 * Set the field_key property
134 120 *
135 121 * @since 2.03.05
136 - *
137 - * @return void
138 122 */
139 123 private function set_field_key() {
140 124 $this->field_key = $this->db_row->field_key;
141 125 }
@@ -143,10 +127,8 @@
143 127 /**
144 128 * Set the field_settings property
145 129 *
146 130 * @since 2.03.05
147 - *
148 - * @return void
149 131 */
150 132 protected function set_field_settings() {
151 133 // Leave as null for free version
152 134 }
@@ -154,10 +136,8 @@
154 136 /**
155 137 * Set the options property
156 138 *
157 139 * @since 2.03.05
158 - *
159 - * @return void
160 140 */
161 141 protected function set_options() {
162 142 $field_obj = FrmFieldFactory::get_field_object( $this->db_row );
163 143 $this->options = $field_obj->get_options( array() );
@@ -168,10 +148,8 @@
168 148 *
169 149 * @since 2.03.05
170 150 *
171 151 * @param array $args
172 - *
173 - * @return void
174 152 */
175 153 protected function set_html_name( $args ) {
176 154 if ( isset( $args['html_name'] ) ) {
177 155 $this->html_name = (string) $args['html_name'];
@@ -183,10 +161,8 @@
183 161 *
184 162 * @since 2.03.05
185 163 *
186 164 * @param array $args
187 - *
188 - * @return void
189 165 */
190 166 protected function set_value( $args ) {
191 167 if ( isset( $args['value'] ) ) {
192 168 $this->value = (string) $args['value'];
@@ -198,10 +174,8 @@
198 174 *
199 175 * @since 2.03.05
200 176 *
201 177 * @param array $args
202 - *
203 - * @return void
204 178 */
205 179 protected function set_source( $args ) {
206 180 if ( isset( $args['source'] ) ) {
207 181 $this->source = (string) $args['source'];
@@ -208,21 +182,8 @@
208 182 }
209 183 }
210 184
211 185 /**
212 - * @since 6.16.2
213 - *
214 - * @param array $args
215 - *
216 - * @return void
217 - */
218 - protected function set_truncate( $args ) {
219 - if ( isset( $args['truncate'] ) && is_numeric( $args['truncate'] ) ) {
220 - $this->truncate = (int) $args['truncate'];
221 - }
222 - }
223 -
224 - /**
225 186 * Check if object has any options
226 187 *
227 188 * @since 2.03.05
228 189 *
@@ -246,10 +207,8 @@
246 207 /**
247 208 * Display the field value selector (dropdown or text field)
248 209 *
249 210 * @since 2.03.05
250 - *
251 - * @return void
252 211 */
253 212 public function display() {
254 213 if ( $this->has_options() ) {
255 214 $this->display_dropdown();
@@ -261,10 +220,8 @@
261 220 /**
262 221 * Print the field value text box
263 222 *
264 223 * @since 2.03.05
265 - *
266 - * @return void
267 224 */
268 225 public function display_text_box() {
269 226 echo '<input type="text" name="' . esc_attr( $this->html_name ) . '" value="' . esc_attr( trim( $this->value ) ) . '" />';
270 227 }
@@ -272,18 +229,14 @@
272 229 /**
273 230 * Display the field value selector
274 231 *
275 232 * @since 2.03.05
276 - *
277 - * @return void
278 233 */
279 234 protected function display_dropdown() {
280 235 echo '<select name="' . esc_attr( $this->html_name ) . '">';
281 - echo '<option value="">' . esc_html( $this->blank_option_label ) . '</option>';
236 + echo '<option value="">' . esc_attr( $this->blank_option_label ) . '</option>';
282 237
283 238 if ( ! empty( $this->options ) ) {
284 - $truncate = $this->truncate ?? 25;
285 -
286 239 foreach ( $this->options as $key => $value ) {
287 240 if ( $value == '' ) {
288 241 continue;
289 242 }
@@ -288,24 +241,13 @@
288 241 continue;
289 242 }
290 243
291 244 $option = $this->get_single_field_option( $key, $value );
292 - $option->print_single_option( $this->value, $truncate, $this->use_value_as_label_in_dropdown() );
245 + $option->print_single_option( $this->value, 25 );
293 246 }
294 247 }
295 248
296 249 echo '</select>';
297 - }
298 -
299 - /**
300 - * Whether to use the field value as the option label in the dropdown when the label is empty.
301 - *
302 - * @since 6.25.1
303 - *
304 - * @return bool
305 - */
306 - protected function use_value_as_label_in_dropdown() {
307 - return false;
308 250 }
309 251
310 252 /**
311 253 * Get an instance of FrmFieldOption