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

95 lines 2.5 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 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 die( 'You are not allowed to call this page directly.' );
10 }
11
12 if ( isset( $field['post_field'] ) && $field['post_field'] === 'post_category' && FrmAppHelper::pro_is_installed() ) {
13 echo FrmProPost::get_category_dropdown( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
14 $field,
15 array(
16 'location' => 'front',
17 'name' => $field_name, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
18 'id' => $html_id, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
19 )
20 );
21 } else {
22 if ( $read_only ) {
23 ?>
24 <select <?php do_action( 'frm_field_input_html', $field ); ?>>
25 <?php } else { ?>
26 <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $html_id ); ?>" <?php do_action( 'frm_field_input_html', $field ); ?>>
27 <?php
28 }
29
30 $placeholder = FrmFieldsController::add_placeholder_to_select( $field );
31
32 $skipped = false;
33 $other_opt = false;
34 $other_checked = false;
35
36 if ( empty( $field['options'] ) ) {
37 $field['options'] = array();
38 }
39
40 if ( ! $placeholder ) {
41 /**
42 * @since 6.16.2
43 *
44 * @param array $field
45 */
46 do_action( 'frm_dropdown_field_after_no_placeholder_option', $field );
47 }
48
49 foreach ( $field['options'] as $opt_key => $opt ) {
50 $field_val = FrmFieldsHelper::get_value_from_array( $opt, $opt_key, $field );
51 $opt = FrmFieldsHelper::get_label_from_array( $opt, $opt_key, $field );
52 $selected = FrmAppHelper::check_selected( $field['value'], $field_val );
53 if ( $other_opt === false ) {
54 $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field', 'field_name', 'opt_key' ), $other_opt, $selected );
55 if ( FrmFieldsHelper::is_other_opt( $opt_key ) && $selected ) {
56 $other_checked = true;
57 }
58 }
59
60 if ( $placeholder && $opt == '' && ! $skipped ) {
61 $skipped = true;
62 continue;
63 }
64
65 $option_params = array(
66 'value' => $field_val,
67 );
68
69 if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
70 $option_params['class'] = 'frm_other_trigger';
71 }
72
73 FrmHtmlHelper::echo_dropdown_option( $opt, (bool) $selected, $option_params );
74 unset( $option_params );
75 }//end foreach
76 ?>
77 </select>
78 <?php
79
80 if ( isset( $other_args ) ) {
81 FrmFieldsHelper::include_other_input(
82 array(
83 'other_opt' => $other_opt,
84 'read_only' => $read_only,
85 'checked' => $other_checked,
86 'name' => $other_args['name'],
87 'value' => $other_args['value'],
88 'field' => $field,
89 'html_id' => $html_id,
90 'opt_key' => false,
91 )
92 );
93 }
94 }//end if
95