PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 3.5.2
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v3.5.2
3.5.2 3.5.1 3.5.0 3.4.8 3.4.7 3.4.6 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5.1 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.6.1 1.6.7 1.7.0 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.2 1.7.2.1 1.7.2.2 1.7.3 1.7.4 1.7.5 1.7.5.1 1.7.5.2 1.7.6 1.7.7 1.7.7.1 1.7.7.2 1.7.8 1.7.9 1.8.0 1.8.0.1 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.0.1 1.9.1 1.9.2 1.9.3 1.9.4 1.9.4.1 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.0.1 2.0.1 2.0.2 2.0.3 2.0.3.1 2.0.4 2.0.4.1 2.0.5 2.0.6 2.0.7 2.0.8 2.0.8.1 2.0.9 3.0.0 3.0.0.1 3.0.1 3.0.2 3.0.3 3.0.3.1 3.0.4 3.0.4.1 3.0.4.2 3.0.5 3.0.5.1 3.0.5.2 3.0.6 3.0.6.1 3.0.7.1 3.0.8 3.0.8.1 3.0.9 3.0.9.1 3.0.9.2 3.0.9.3 3.0.9.4 3.0.9.5 3.1.0 3.1.1 3.1.2 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.3.0 3.4.0 3.4.1 3.4.2 3.4.2.1 3.4.3 3.4.4 3.4.5 trunk 1.0 1.0.1 1.0.2 1.0.3
everest-forms / includes / fields / class-evf-field-checkbox.php
everest-forms / includes / fields Last commit date
class-evf-field-address.php 1 year ago class-evf-field-ai.php 1 year ago class-evf-field-captcha.php 4 weeks ago class-evf-field-checkbox.php 2 months ago class-evf-field-color.php 4 weeks ago class-evf-field-country.php 2 months ago class-evf-field-credit-card.php 4 weeks ago class-evf-field-date-time.php 4 weeks ago class-evf-field-divider.php 2 years ago class-evf-field-email.php 1 year ago class-evf-field-file-upload.php 1 year ago class-evf-field-first-name.php 1 year ago class-evf-field-hcaptcha.php 4 months ago class-evf-field-hidden.php 1 year ago class-evf-field-html.php 9 months ago class-evf-field-image-upload.php 1 year ago class-evf-field-last-name.php 1 year ago class-evf-field-likert.php 1 year ago class-evf-field-lookup.php 4 weeks ago class-evf-field-number.php 1 year ago class-evf-field-password.php 4 weeks ago class-evf-field-payment-authorize-net.php 4 weeks ago class-evf-field-payment-checkbox.php 4 weeks ago class-evf-field-payment-coupon.php 4 weeks ago class-evf-field-payment-gateway-selector.php 4 weeks ago class-evf-field-payment-quantity.php 4 weeks ago class-evf-field-payment-radio.php 4 weeks ago class-evf-field-payment-single.php 4 weeks ago class-evf-field-payment-square.php 1 year ago class-evf-field-payment-subscription-plan.php 4 weeks ago class-evf-field-payment-subtotal.php 4 weeks ago class-evf-field-payment-total.php 4 weeks ago class-evf-field-phone.php 1 year ago class-evf-field-privacy-policy.php 2 months ago class-evf-field-private-note.php 1 year ago class-evf-field-progress.php 4 weeks ago class-evf-field-radio.php 2 months ago class-evf-field-range-slider.php 4 weeks ago class-evf-field-rating.php 2 months ago class-evf-field-recaptcha.php 4 months ago class-evf-field-repeater.php 4 weeks ago class-evf-field-reset.php 4 weeks ago class-evf-field-scale-rating.php 1 year ago class-evf-field-select.php 1 year ago class-evf-field-signature.php 4 weeks ago class-evf-field-text.php 1 year ago class-evf-field-textarea.php 1 year ago class-evf-field-title.php 2 years ago class-evf-field-turnstile.php 4 months ago class-evf-field-url.php 1 year ago class-evf-field-wysiwyg.php 2 months ago class-evf-field-yes-no.php 1 year ago payment-amount-helpers.php 4 weeks ago
class-evf-field-checkbox.php
572 lines
1 <?php
2 /**
3 * Checkbox field.
4 *
5 * @package EverestForms\Fields
6 * @since 1.0.0
7 */
8
9 defined( 'ABSPATH' ) || exit;
10
11 /**
12 * EVF_Field_Checkbox class.
13 */
14 class EVF_Field_Checkbox extends EVF_Form_Fields {
15
16 /**
17 * Constructor.
18 */
19 public function __construct() {
20 $this->name = esc_html__( 'Checkboxes', 'everest-forms' );
21 $this->type = 'checkbox';
22 $this->icon = 'evf-icon evf-icon-checkbox';
23 $this->order = 70;
24 $this->group = 'general';
25 $this->defaults = array(
26 1 => array(
27 'label' => esc_html__( 'First Choice', 'everest-forms' ),
28 'value' => '',
29 'image' => '',
30 'default' => '',
31 ),
32 2 => array(
33 'label' => esc_html__( 'Second Choice', 'everest-forms' ),
34 'value' => '',
35 'image' => '',
36 'default' => '',
37 ),
38 3 => array(
39 'label' => esc_html__( 'Third Choice', 'everest-forms' ),
40 'value' => '',
41 'image' => '',
42 'default' => '',
43 ),
44 );
45 $this->settings = array(
46 'basic-options' => array(
47 'field_options' => array(
48 'label',
49 'choices',
50 'choices_images',
51 'description',
52 'required',
53 'required_field_message_setting',
54 'required_field_message',
55 ),
56 ),
57 'advanced-options' => array(
58 'field_options' => array(
59 'meta',
60 'randomize',
61 'show_values',
62 'input_columns',
63 'choice_limit',
64 'label_hide',
65 'css',
66 'select_all',
67 ),
68 ),
69 );
70
71 parent::__construct();
72 }
73
74 /**
75 * Hook in tabs.
76 */
77 public function init_hooks() {
78 add_filter( 'everest_forms_html_field_value', array( $this, 'html_field_value' ), 10, 4 );
79 add_filter( 'everest_forms_field_properties_' . $this->type, array( $this, 'field_properties' ), 5, 3 );
80 }
81
82 /**
83 * Return images, if any, for HTML supported values.
84 *
85 * @since 1.6.0
86 *
87 * @param string $value Field value.
88 * @param array $field Field settings.
89 * @param array $form_data Form data and settings.
90 * @param string $context Value display context.
91 *
92 * @return string
93 */
94 public function html_field_value( $value, $field, $form_data = array(), $context = '' ) {
95 if ( is_serialized( $field ) || in_array( $context, array( 'email-html', 'export-pdf' ), true ) ) {
96 $field_value = evf_maybe_unserialize( $field );
97 $field_type = isset( $field_value['type'] ) ? sanitize_text_field( $field_value['type'] ) : 'checkbox';
98
99 if ( $field_type === $this->type ) {
100 if (
101 'entry-table' !== $context
102 && ! empty( $field_value['label'] )
103 && ! empty( $field_value['images'] )
104 && apply_filters( 'everest_forms_checkbox_field_html_value_images', true, $context )
105 ) {
106 $items = array();
107
108 if ( is_array( $field_value['label'] ) && ! empty( $field_value['label'] ) ) {
109 foreach ( $field_value['label'] as $key => $item_value ) {
110 $label_text = esc_html( wp_unslash( (string) $item_value ) );
111
112 if ( ! empty( $field_value['images'][ $key ] ) ) {
113 $image_url = esc_url( $field_value['images'][ $key ] );
114
115 $items[] = sprintf(
116 '<span style="max-width:200px;display:block;margin:0 0 5px 0;"><img src="%1$s" style="max-width:100%%;display:block;margin:0;" alt="" /></span>%2$s',
117 $image_url,
118 $label_text
119 );
120 } else {
121 $items[] = $label_text;
122 }
123 }
124 }
125
126 return implode( 'export-csv' !== $context ? '<br><br>' : '|', $items );
127 }
128 }
129 }
130
131 return $value;
132 }
133
134 /**
135 * Define additional field properties.
136 *
137 * @since 1.0.0
138 *
139 * @param array $properties Field properties.
140 * @param array $field Field settings.
141 * @param array $form_data Form data and settings.
142 *
143 * @return array of additional field properties.
144 */
145 public function field_properties( $properties, $field, $form_data ) {
146 // Define data.
147 $form_id = absint( $form_data['id'] );
148 $field_id = $field['id'];
149 $choices = $field['choices'];
150
151 // Remove primary input.
152 unset( $properties['inputs']['primary'] );
153
154 // Set input container (ul) properties.
155 $properties['input_container'] = array(
156 'class' => array( ! empty( $field['random'] ) ? 'everest-forms-randomize' : '' ),
157 'data' => array(),
158 'attr' => array(),
159 'id' => "evf-{$form_id}-field_{$field_id}",
160 );
161
162 // Set choice limit.
163 $field['choice_limit'] = empty( $field['choice_limit'] ) ? 0 : (int) $field['choice_limit'];
164 if ( $field['choice_limit'] > 0 ) {
165 $properties['input_container']['data']['choice-limit'] = $field['choice_limit'];
166 }
167
168 // Set input properties.
169 foreach ( $choices as $key => $choice ) {
170 $depth = isset( $choice['depth'] ) ? absint( $choice['depth'] ) : 1;
171
172 // Choice labels should not be left blank, but if they are we provide a basic value.
173 $value = isset( $field['show_values'] ) ? $choice['value'] : $choice['label'];
174 if ( '' === $value ) {
175 if ( 1 === count( $choices ) ) {
176 $value = esc_html__( 'Checked', 'everest-forms' );
177 } else {
178 /* translators: %s - Choice Number. */
179 $value = sprintf( esc_html__( 'Choice %s', 'everest-forms' ), $key );
180 }
181 }
182
183 $properties['inputs'][ $key ] = array(
184 'container' => array(
185 'attr' => array(),
186 'class' => array( "choice-{$key}", "depth-{$depth}" ),
187 'data' => array(),
188 'id' => '',
189 ),
190 'label' => array(
191 'attr' => array(
192 'for' => "evf-{$form_id}-field_{$field_id}_{$key}",
193 ),
194 'class' => array( 'everest-forms-field-label-inline' ),
195 'data' => array(),
196 'id' => '',
197 'text' => evf_string_translation( $form_id, $field_id, $choice['label'], '-choice-' . $key ),
198 ),
199 'attr' => array(
200 'name' => "everest_forms[form_fields][{$field_id}][]",
201 'value' => $value,
202 ),
203 'class' => array( 'input-text' ),
204 'data' => array(),
205 'id' => "evf-{$form_id}-field_{$field_id}_{$key}",
206 'image' => isset( $choice['image'] ) ? $choice['image'] : '',
207 'required' => ! empty( $field['required'] ) ? 'required' : '',
208 'default' => isset( $choice['default'] ),
209 );
210
211 // Rule for choice limit validator.
212 if ( $field['choice_limit'] > 0 ) {
213 $properties['inputs'][ $key ]['data']['rule-check-limit'] = 'true';
214 }
215 }
216
217 // Required class for validation.
218 if ( ! empty( $field['required'] ) ) {
219 $properties['input_container']['class'][] = 'evf-field-required';
220 }
221
222 // Custom properties if enabled image choices.
223 if ( ! empty( $field['choices_images'] ) ) {
224 $properties['input_container']['class'][] = 'everest-forms-image-choices';
225
226 foreach ( $properties['inputs'] as $key => $inputs ) {
227 $properties['inputs'][ $key ]['container']['class'][] = 'everest-forms-image-choices-item';
228 }
229 }
230
231 // Add selected class for choices with defaults.
232 foreach ( $properties['inputs'] as $key => $inputs ) {
233 if ( ! empty( $inputs['default'] ) ) {
234 $properties['inputs'][ $key ]['container']['class'][] = 'everest-forms-selected';
235 }
236 }
237
238 return $properties;
239 }
240
241 /**
242 * Randomize order of choices.
243 *
244 * @since 1.6.0
245 * @param array $field Field Data.
246 */
247 public function randomize( $field ) {
248 $args = array(
249 'slug' => 'random',
250 'content' => $this->field_element(
251 'toggle',
252 $field,
253 array(
254 'slug' => 'random',
255 'value' => isset( $field['random'] ) ? '1' : '0',
256 'desc' => esc_html__( 'Randomize Choices', 'everest-forms' ),
257 'tooltip' => esc_html__( 'Check this option to randomize the order of the choices.', 'everest-forms' ),
258 ),
259 false
260 ),
261 );
262 $this->field_element( 'row', $field, $args );
263 }
264
265 /**
266 * Choice limit field option.
267 *
268 * @since 1.6.0
269 * @param array $field Field data.
270 */
271 public function choice_limit( $field ) {
272 $choice_limit_label = $this->field_element(
273 'label',
274 $field,
275 array(
276 'slug' => 'choice_limit',
277 'value' => esc_html__( 'Choice Limit', 'everest-forms' ),
278 'tooltip' => esc_html__( 'Check this option to limit the number of checkboxes a user can select.', 'everest-forms' ),
279 ),
280 false
281 );
282 $choice_limit_input = $this->field_element(
283 'text',
284 $field,
285 array(
286 'slug' => 'choice_limit',
287 'value' => ( isset( $field['choice_limit'] ) && $field['choice_limit'] > 0 ) ? (int) $field['choice_limit'] : '',
288 'type' => 'number',
289 ),
290 false
291 );
292
293 $args = array(
294 'slug' => 'choice_limit',
295 'content' => $choice_limit_label . $choice_limit_input,
296 );
297 $this->field_element( 'row', $field, $args );
298 }
299
300 /**
301 * Show values field option.
302 *
303 * @param array $field Field Data.
304 */
305 public function show_values( $field ) {
306 // Show Values toggle option. This option will only show if already used or if manually enabled by a filter.
307 if ( ! empty( $field['show_values'] ) || apply_filters( 'everest_forms_fields_show_options_setting', false ) ) {
308 $args = array(
309 'slug' => 'show_values',
310 'content' => $this->field_element(
311 'checkbox',
312 $field,
313 array(
314 'slug' => 'show_values',
315 'value' => isset( $field['show_values'] ) ? $field['show_values'] : '0',
316 'desc' => __( 'Show Values', 'everest-forms' ),
317 'tooltip' => __( 'Check this to manually set form field values.', 'everest-forms' ),
318 ),
319 false
320 ),
321 );
322 $this->field_element( 'row', $field, $args );
323 }
324 }
325
326 /**
327 * Select All checkbox.
328 *
329 * @since 1.8.4
330 * @param array $field Field data.
331 */
332 public function select_all( $field ) {
333 $fld = $this->field_element(
334 'checkbox',
335 $field,
336 array(
337 'slug' => 'select_all',
338 'value' => isset( $field['select_all'] ) ? '1' : '0',
339 'desc' => esc_html__( 'Select All', 'everest-forms' ),
340 'tooltip' => esc_html__( 'Check this option to select all the options.', 'everest-forms' ),
341 ),
342 false
343 );
344
345 $args = array(
346 'slug' => 'select_all',
347 'content' => $fld,
348 );
349 $this->field_element( 'row', $field, $args );
350 }
351
352 /**
353 * Field preview inside the builder.
354 *
355 * @since 1.0.0
356 *
357 * @param array $field Field data and settings.
358 */
359 public function field_preview( $field ) {
360 // Label.
361 $this->field_preview_option( 'label', $field );
362
363 // Choices.
364 $this->field_preview_option( 'choices', $field );
365
366 // Description.
367 $this->field_preview_option( 'description', $field );
368 }
369
370 /**
371 * Field display on the form front-end.
372 *
373 * @since 1.0.0
374 *
375 * @param array $field Field Data.
376 * @param array $field_atts Field attributes.
377 * @param array $form_data All Form Data.
378 */
379 public function field_display( $field, $field_atts, $form_data ) {
380 // Define data.
381 $container = $field['properties']['input_container'];
382 $choices = $field['properties']['inputs'];
383 $select_all = isset( $field['select_all'] ) ? $field['select_all'] : '0';
384
385 // List.
386 printf( '<ul %s>', evf_html_attributes( $container['id'], $container['class'], $container['data'], $container['attr'] ) );
387
388 // Select All Checkbox.
389 if ( '1' === $select_all ) {
390 printf( '<li class="evf-select-all-checkbox-li"><input type="checkbox" id="evfCheckAll" class="evf-select-all-checkbox"><label for="evfCheckAll">' . esc_html__( 'Select All', 'everest-forms' ) . '</label></li>' );
391 }
392
393 foreach ( $choices as $choice ) {
394 if ( empty( $choice['container'] ) ) {
395 continue;
396 }
397
398 // Conditional logic.
399 if ( isset( $choices['primary'] ) ) {
400 $choice['attr']['conditional_id'] = $choices['primary']['attr']['conditional_id'];
401 if ( isset( $choices['primary']['attr']['conditional_rules'] ) ) {
402 $choice['attr']['conditional_rules'] = $choices['primary']['attr']['conditional_rules'];
403 }
404 }
405
406 printf( '<li %s>', evf_html_attributes( $choice['container']['id'], $choice['container']['class'], $choice['container']['data'], $choice['container']['attr'] ) );
407
408 if ( ! empty( $field['choices_images'] ) ) {
409 // Make image choices keyboard-accessible.
410 $choice['label']['attr']['tabindex'] = 0;
411
412 // Image choices.
413 printf( '<label %s>', evf_html_attributes( $choice['label']['id'], $choice['label']['class'], $choice['label']['data'], $choice['label']['attr'] ) );
414
415 if ( ! empty( $choice['image'] ) ) {
416 printf(
417 '<span class="everest-forms-image-choices-image"><img src="%s" alt="%s"%s></span>',
418 esc_url( $choice['image'] ),
419 esc_attr( $choice['label']['text'] ),
420 ! empty( $choice['label']['text'] ) ? ' title="' . esc_attr( $choice['label']['text'] ) . '"' : ''
421 );
422 }
423
424 echo '<br>';
425
426 $choice['attr']['tabindex'] = '-1';
427 printf( '<input type="checkbox" %s %s %s>', evf_html_attributes( $choice['id'], $choice['class'], $choice['data'], $choice['attr'] ), esc_attr( $choice['required'] ), checked( '1', $choice['default'], false ) );
428 echo '<label class="everest-forms-image-choices-label"' . ( isset( $choice['id'] ) ? ' for="' . esc_attr( $choice['id'] ) . '"' : '' ) . '>' . wp_kses_post( $choice['label']['text'] ) . '</label>';
429 echo '</label>';
430 } else {
431 // Normal display.
432 printf( '<input type="checkbox" %s %s %s>', evf_html_attributes( $choice['id'], $choice['class'], $choice['data'], $choice['attr'] ), esc_attr( $choice['required'] ), checked( '1', $choice['default'], false ) );
433 printf( '<label %s>%s</label>', evf_html_attributes( $choice['label']['id'], $choice['label']['class'], $choice['label']['data'], $choice['label']['attr'] ), wp_kses_post( $choice['label']['text'] ) );
434 }
435
436 echo '</li>';
437 }
438
439 echo '</ul>';
440 }
441
442 /**
443 * Edit form field display on the entry back-end.
444 *
445 * @since 1.7.0
446 *
447 * @param array $entry_field Entry field data.
448 * @param array $field Field data.
449 * @param array $form_data Form data and settings.
450 */
451 public function edit_form_field_display( $entry_field, $field, $form_data ) {
452 $value_choices = ! empty( $entry_field['value_raw'] ) ? $entry_field['value_raw'] : array();
453
454 $this->remove_field_choices_defaults( $field, $field['properties'] );
455
456 foreach ( $value_choices as $input => $single_value ) {
457 $field['properties'] = $this->get_single_field_property_value( $single_value, sanitize_key( $input ), $field['properties'], $field );
458 }
459
460 $this->field_display( $field, null, $form_data );
461 }
462
463 /**
464 * Validates field on form submit.
465 *
466 * @since 1.6.0
467 *
468 * @param int $field_id Field ID.
469 * @param array $field_submit Submitted data.
470 * @param array $form_data Form data.
471 */
472 public function validate( $field_id, $field_submit, $form_data ) {
473 $field_submit = (array) $field_submit;
474 $form_id = $form_data['id'];
475 $fields = $form_data['form_fields'];
476 $choice_limit = empty( $fields[ $field_id ]['choice_limit'] ) ? 0 : (int) $fields[ $field_id ]['choice_limit'];
477 $entry = $form_data['entry'];
478 $visible = apply_filters( 'everest_forms_visible_fields', true, $form_data['form_fields'][ $field_id ], $entry, $form_data );
479 $required_message = isset( $form_data['form_fields'][ $field_id ]['required-field-message'], $form_data['form_fields'][ $field_id ]['required_field_message_setting'] ) && ! empty( $form_data['form_fields'][ $field_id ]['required-field-message'] ) && 'individual' == $form_data['form_fields'][ $field_id ]['required_field_message_setting'] ? $form_data['form_fields'][ $field_id ]['required-field-message'] : get_option( 'everest_forms_required_validation' );
480
481 if ( false === $visible ) {
482 return;
483 }
484
485 // Generating the error.
486 if ( $choice_limit > 0 && $choice_limit < count( $field_submit ) ) {
487 $error = get_option( 'everest_forms_check_limit_validation', esc_html__( 'You have exceeded number of allowed selections: {#}.', 'everest-forms' ) );
488 $error = str_replace( '{#}', $choice_limit, $error );
489 }
490
491 // Basic required check.
492 if ( ! empty( $fields[ $field_id ]['required'] ) && ( empty( $field_submit ) || ( 1 === count( $field_submit ) && empty( $field_submit[0] ) ) ) ) {
493 $error = $required_message;
494 }
495
496 if ( ! empty( $error ) ) {
497 evf()->task->errors[ $form_id ][ $field_id ] = $error;
498 }
499 }
500
501 /**
502 * Formats and sanitizes field.
503 *
504 * @since 1.0.0
505 *
506 * @param string $field_id Field Id.
507 * @param array $field_submit Submitted Field.
508 * @param array $form_data All Form Data.
509 * @param string $meta_key Field Meta Key.
510 */
511 public function format( $field_id, $field_submit, $form_data, $meta_key ) {
512 $field_submit = (array) $field_submit;
513 $field = $form_data['form_fields'][ $field_id ];
514 $name = make_clickable( $field['label'] );
515 $value_raw = evf_sanitize_array_combine( $field_submit );
516 $choice_keys = array();
517
518 $data = array(
519 'id' => $field_id,
520 'type' => $this->type,
521 'value' => array(
522 'name' => $name,
523 'type' => $this->type,
524 ),
525 'meta_key' => $meta_key,
526 'value_raw' => $value_raw,
527 );
528
529 /*
530 * If show_values is true, that means values posted are the raw values
531 * and not the labels. So we need to get the label values.
532 */
533 if ( ! empty( $field['show_values'] ) && '1' === $field['show_values'] ) {
534 foreach ( $field_submit as $item ) {
535 foreach ( $field['choices'] as $key => $choice ) {
536 if ( $item === $choice['value'] || ( empty( $choice['value']['label'] ) && (int) str_replace( 'Choice ', '', $item ) === $key ) ) {
537 $value[] = $choice['label'];
538 $choice_keys[] = $key;
539 break;
540 }
541 }
542 }
543
544 $data['value']['label'] = ! empty( $value ) ? evf_sanitize_array_combine( $value ) : '';
545 } else {
546 $data['value']['label'] = $value_raw;
547
548 // Determine choices keys, this is needed for image choices.
549 foreach ( $field_submit as $item ) {
550 foreach ( $field['choices'] as $key => $choice ) {
551 if ( $item === $choice['label'] ) {
552 $choice_keys[] = $key;
553 break;
554 }
555 }
556 }
557 }
558
559 // Images choices are enabled, lookup and store image URLs.
560 if ( ! empty( $choice_keys ) && ! empty( $field['choices_images'] ) ) {
561 $data['value']['images'] = array();
562
563 foreach ( $choice_keys as $key ) {
564 $data['value']['images'][] = ! empty( $field['choices'][ $key ]['image'] ) ? esc_url_raw( $field['choices'][ $key ]['image'] ) : '';
565 }
566 }
567
568 // Push field details to be saved.
569 evf()->task->form_fields[ $field_id ] = $data;
570 }
571 }
572