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
← All changes | classes/views/frm-fields/front-end/radio-field.php +36 -9 6.27 → trunk View file →
@@ -7,9 +7,19 @@
7 7 * Show the radio field on the front-end.
8 8 * Extra line breaks show as space on the front-end when
9 9 * the form is double filtered and not minimized.
10 10 *
11 + * @var array $field
12 + * @var string $field_name
13 + * @var bool $read_only
14 + * @var string $html_id
15 + * @var array|null $args
16 + *
11 17 * @phpcs:disable Generic.WhiteSpace.ScopeIndent
18 + *
19 + * @since 6.30 Added `$hide_label`.
20 + *
21 + * @var bool $hide_label
12 22 */
13 23
14 24 if ( isset( $field['post_field'] ) && $field['post_field'] === 'post_category' ) {
15 25 $type = $field['type'];
@@ -14,13 +24,21 @@
14 24 if ( isset( $field['post_field'] ) && $field['post_field'] === 'post_category' ) {
15 25 $type = $field['type'];
16 26 do_action( 'frm_after_checkbox', compact( 'field', 'field_name', 'type' ) );
17 27 } elseif ( is_array( $field['options'] ) ) {
28 + if ( FrmFieldsHelper::should_skip_rendering_choices_for_field( $field ) ) {
29 + return;
30 + }
31 +
18 32 foreach ( $field['options'] as $opt_key => $opt ) {
19 - if ( isset( $shortcode_atts ) && isset( $shortcode_atts['opt'] ) && ( $shortcode_atts['opt'] !== $opt_key ) ) {
33 + if ( isset( $shortcode_atts ) && isset( $shortcode_atts['opt'] ) && $shortcode_atts['opt'] !== $opt_key ) {
20 34 continue;
21 35 }
22 36
37 + if ( FrmFieldsHelper::should_hide_field_choice( $opt_key, $field ) ) {
38 + continue;
39 + }
40 +
23 41 $field_val = FrmFieldsHelper::get_value_from_array( $opt, $opt_key, $field );
24 42 $opt = FrmFieldsHelper::get_label_from_array( $opt, $opt_key, $field );
25 43
26 44 /**
@@ -28,20 +46,23 @@
28 46 *
29 47 * @since 5.0.04
30 48 *
31 49 * @param string $label Label HTML.
32 - * @param array $args The arguments. Contains `field`.
50 + * @param array $args The arguments. Contains `field` and `field_val`.
33 51 */
34 - $label = apply_filters( 'frm_choice_field_option_label', $opt, compact( 'field' ) );
52 + $label = apply_filters( 'frm_choice_field_option_label', $opt, compact( 'field', 'field_val' ) );
35 53 ?>
36 54 <div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ); ?>" id="<?php echo esc_attr( FrmFieldsHelper::get_checkbox_id( $field, $opt_key, 'radio' ) ); ?>"><?php
37 55
38 - if ( ! isset( $shortcode_atts ) || ! isset( $shortcode_atts['label'] ) || $shortcode_atts['label'] ) {
56 + $checked = FrmAppHelper::check_selected( $field['value'], $field_val ) ? 'checked="checked" ' : ' ';
57 + $should_echo_disabled_att = FrmFieldsHelper::should_disable_choice( $opt_key, trim( $checked ) !== '', $field );
58 +
59 + if ( empty( $hide_label ) ) {
39 60 $label_attributes = array(
40 61 'for' => $html_id . '-' . $opt_key,
41 62 );
42 63
43 - if ( $read_only ) {
64 + if ( $read_only || $should_echo_disabled_att ) {
44 65 $label_attributes['class'] = 'frm-label-disabled';
45 66 }
46 67 ?>
47 68 <label <?php FrmAppHelper::array_to_html_params( $label_attributes, true ); ?>>
@@ -53,14 +74,20 @@
53 74 $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
54 75 ?>
55 76 <input type="radio" name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ); ?>" value="<?php echo esc_attr( $field_val ); ?>"
56 77 <?php
57 - echo $checked . ' '; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
58 78 do_action( 'frm_field_input_html', $field );
79 + echo $checked; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
80 +
81 + if ( $should_echo_disabled_att ) {
82 + echo 'disabled="disabled" ';
83 + }
59 84 ?>/><?php
60 -
61 - if ( ! isset( $shortcode_atts ) || ! isset( $shortcode_atts['label'] ) || $shortcode_atts['label'] ) {
62 - echo ' ' . FrmAppHelper::kses( $label, 'all' ) . '</label>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
85 + if ( empty( $hide_label ) ) {
86 + echo ' ';
87 + FrmAppHelper::kses_echo( $label, 'all' );
88 + FrmFieldsHelper::after_choice_input( $field, $opt_key );
89 + echo '</label>';
63 90 }
64 91
65 92 $other_args = array(
66 93 'other_opt' => $other_opt,