PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.26.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.26.1
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 / checkbox-field.php

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

103 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 die( 'You are not allowed to call this page directly.' );
4 }
5
6 /**
7 * Show the checkbox field on the front-end.
8 * Extra line breaks show as space on the front-end when
9 * the form is double filtered and not minimized.
10 *
11 * @phpcs:disable Generic.WhiteSpace.ScopeIndent
12 */
13
14 if ( isset( $field['post_field'] ) && $field['post_field'] === 'post_category' ) {
15 $type = $field['type'];
16 do_action( 'frm_after_checkbox', compact( 'field', 'field_name', 'type' ) );
17 } elseif ( $field['options'] ) {
18 $option_index = 0;
19
20 foreach ( $field['options'] as $opt_key => $opt ) {
21 if ( isset( $shortcode_atts ) && isset( $shortcode_atts['opt'] ) && $shortcode_atts['opt'] !== $opt_key ) {
22 continue;
23 }
24
25 $field_val = FrmFieldsHelper::get_value_from_array( $opt, $opt_key, $field );
26 $opt = FrmFieldsHelper::get_label_from_array( $opt, $opt_key, $field );
27
28 /**
29 * Allows changing the HTML of option label in choice field (radio, checkbox,...).
30 *
31 * @since 5.0.04
32 *
33 * @param string $label Label HTML.
34 * @param array $args The arguments. Contains `field`.
35 */
36 $label = apply_filters( 'frm_choice_field_option_label', $opt, compact( 'field' ) );
37
38 // init.
39 $checked = '';
40
41 if ( ! FrmFieldsHelper::is_other_opt( $opt_key ) ) {
42 // Let the checked state of 'Other' fields be determined solely by FrmFieldsHelper::prepare_other_input as below.
43 // Without this check, one 'Other' field being checked leads to making all 'Other' fields checked on submit error
44 // since they all have the same value attr of 'Other'.
45 $checked = FrmAppHelper::check_selected( $field['value'], $field_val ) ? ' checked="checked"' : '';
46 }
47
48 // Check if other opt, and get values for other field if needed
49 $other_opt = false;
50 $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field', 'field_name', 'opt_key', 'field_val' ), $other_opt, $checked );
51
52 ?>
53 <div class="<?php echo esc_attr( apply_filters( 'frm_checkbox_class', 'frm_checkbox', $field, $field_val ) ); ?>" id="<?php echo esc_attr( FrmFieldsHelper::get_checkbox_id( $field, $opt_key ) ); ?>"><?php
54
55 if ( ! isset( $shortcode_atts ) || ! isset( $shortcode_atts['label'] ) || $shortcode_atts['label'] ) {
56 $label_attributes = array(
57 'for' => $html_id . '-' . $opt_key,
58 );
59
60 if ( $read_only ) {
61 $label_attributes['class'] = 'frm-label-disabled';
62 }
63 ?>
64 <label <?php FrmAppHelper::array_to_html_params( $label_attributes, true ); ?>>
65 <?php
66 }
67
68 ?><input type="checkbox" name="<?php echo esc_attr( $field_name ); ?>[<?php echo esc_attr( $other_opt ? $opt_key : '' ); ?>]" id="<?php echo esc_attr( $html_id ); ?>-<?php echo esc_attr( $opt_key ); ?>" value="<?php echo esc_attr( $field_val ); ?>"<?php
69 echo $checked . ' '; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
70
71 do_action( 'frm_field_input_html', $field );
72
73 if ( 0 === $option_index && FrmField::is_required( $field ) ) {
74 echo ' aria-required="true" ';
75 }
76
77 ?> /><?php
78
79 if ( ! isset( $shortcode_atts ) || ! isset( $shortcode_atts['label'] ) || $shortcode_atts['label'] ) {
80 echo ' ' . FrmAppHelper::kses( $label, 'all' ) . '</label>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
81 }
82
83 $other_args = array(
84 'other_opt' => $other_opt,
85 'read_only' => $read_only,
86 'checked' => $checked,
87 'name' => $other_args['name'],
88 'value' => $other_args['value'],
89 'field' => $field,
90 'html_id' => $html_id,
91 'opt_key' => $opt_key,
92 'opt_label' => $opt,
93 );
94 FrmFieldsHelper::include_other_input( $other_args );
95
96 unset( $other_opt, $other_args, $checked );
97
98 ?></div>
99 <?php
100 ++$option_index;
101 }//end foreach
102 }//end if
103