PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
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
formidable / classes / views / frm-fields / front-end / dropdown-field.php

dropdown-field.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More trunk, at classes/views/frm-fields/front-end/dropdown-field.php

118 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package Formidable
4 *
5 * @var array $field
6 * @var array|null $args
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 die( 'You are not allowed to call this page directly.' );
11 }
12
13 if ( isset( $field['post_field'] ) && $field['post_field'] === 'post_category' && FrmAppHelper::pro_is_installed() ) {
14 $category_dropdown_args = array(
15 'location' => 'front',
16 'name' => $field_name,
17 'id' => $html_id,
18 );
19 echo FrmProPost::get_category_dropdown( $field, $category_dropdown_args ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
20 } else {
21 if ( FrmFieldsHelper::should_skip_rendering_choices_for_field( $field ) ) {
22 return;
23 }
24
25 if ( $read_only ) {
26 ?>
27 <select <?php do_action( 'frm_field_input_html', $field ); ?>>
28 <?php
29 } else {
30 ?>
31 <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $html_id ); ?>" <?php do_action( 'frm_field_input_html', $field ); ?>>
32 <?php
33 }
34
35 $placeholder = FrmFieldsController::add_placeholder_to_select( $field );
36 $skipped = false;
37 $other_opt = false;
38 $other_checked = false;
39
40 if ( empty( $field['options'] ) ) {
41 $field['options'] = array();
42 }
43
44 if ( ! $placeholder ) {
45 /**
46 * @since 6.16.2
47 *
48 * @param array $field
49 */
50 do_action( 'frm_dropdown_field_after_no_placeholder_option', $field );
51 }
52
53 foreach ( $field['options'] as $opt_key => $opt ) {
54 if ( FrmFieldsHelper::should_hide_field_choice( $opt_key, $field ) ) {
55 continue;
56 }
57
58 $field_val = FrmFieldsHelper::get_value_from_array( $opt, $opt_key, $field );
59 $opt = FrmFieldsHelper::get_label_from_array( $opt, $opt_key, $field );
60 $selected = FrmAppHelper::check_selected( $field['value'], $field_val );
61
62 if ( $other_opt === false ) {
63 $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field', 'field_name', 'opt_key' ), $other_opt, $selected );
64
65 if ( FrmFieldsHelper::is_other_opt( $opt_key ) && $selected ) {
66 $other_checked = true;
67 }
68 }
69
70 // phpcs:ignore Universal.Operators.StrictComparisons
71 if ( $placeholder && $opt == '' && ! $skipped ) {
72 $skipped = true;
73 continue;
74 }
75
76 $option_params = array(
77 'value' => $field_val,
78 );
79
80 if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
81 $option_params['class'] = 'frm_other_trigger';
82 }
83
84 if ( FrmFieldsHelper::should_disable_choice( $opt_key, $selected, $field ) ) {
85 $option_params['disabled'] = 'disabled';
86 }
87
88 echo '<option ';
89 FrmAppHelper::array_to_html_params( $option_params, true );
90 selected( (bool) $selected );
91 echo '>';
92 echo esc_html( $opt === '' ? ' ' : $opt );
93 FrmFieldsHelper::after_choice_input( $field, $opt_key );
94
95 echo '</option>';
96
97 unset( $option_params );
98 }//end foreach
99 ?>
100 </select>
101 <?php
102
103 if ( isset( $other_args ) ) {
104 FrmFieldsHelper::include_other_input(
105 array(
106 'other_opt' => $other_opt,
107 'read_only' => $read_only,
108 'checked' => $other_checked,
109 'name' => $other_args['name'],
110 'value' => $other_args['value'],
111 'field' => $field,
112 'html_id' => $html_id,
113 'opt_key' => false,
114 )
115 );
116 }
117 }//end if
118