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/single-option.php +42 -4 6.4.2 → trunk View file →
@@ -1,5 +1,21 @@
1 1 <?php
2 +/**
3 + * Single option row in field settings.
4 + *
5 + * @package Formidable
6 + *
7 + * @var array $field Field data including 'id', 'separate_value', 'do_not_include_icons'.
8 + * @var string $opt_key Option key.
9 + * @var string $opt Option label.
10 + * @var string $field_val Saved value for the option.
11 + * @var string $html_id HTML id prefix for the row.
12 + * @var string $field_name HTML name attribute for the input.
13 + * @var string $default_type Input type (radio/checkbox/text).
14 + * @var bool $checked Whether the option is checked.
15 + * @var int $options_count Total number of options.
16 + */
17 +
2 18 if ( ! defined( 'ABSPATH' ) ) {
3 19 die( 'You are not allowed to call this page directly.' );
4 20 }
5 21 ?>
@@ -4,23 +20,45 @@
4 20 }
5 21 ?>
6 22 <li id="frm_delete_field_<?php echo esc_attr( $field['id'] . '-' . $opt_key ); ?>_container" data-optkey="<?php echo esc_attr( $opt_key ); ?>" class="frm_single_option <?php echo $opt_key === '000' ? 'frm_hidden frm_option_template' : ''; ?>">
7 23 <?php
8 - $show_icons = empty( $field['do_not_include_icons'] );
24 + $show_icons = empty( $field['do_not_include_icons'] );
25 + $is_template = '000' === $opt_key;
9 26
27 + /**
28 + * The add and remove buttons are identical on every option of every field, and no one looks at
29 + * them until that field is opened, so leave them out alongside the icons. The hidden template
30 + * row keeps a copy either way, because that is what the builder fills the real rows in from.
31 + *
32 + * @see addOptionControlsToField() in js/src/admin/admin.js
33 + */
34 + $show_option_controls = $show_icons || $is_template;
35 +
10 36 if ( $show_icons ) {
11 37 FrmAppHelper::icon_by_class( 'frmfont frm_drag_icon frm-drag' );
12 38 }
13 39
14 40 ?>
15 - <input type="<?php echo esc_attr( $default_type ); ?>" name="<?php echo esc_attr( $field_name ); ?>" <?php echo ( isset( $checked ) && $checked ? 'checked="checked"' : '' ); ?> value="<?php echo esc_attr( $field_val ); ?>"/>
41 + <?php if ( in_array( $default_type, array( 'radio', 'checkbox' ), true ) ) : ?>
42 + <input type="<?php echo esc_attr( $default_type ); ?>" name="<?php echo esc_attr( $field_name ); ?>" <?php echo ( ! empty( $checked ) ? 'checked="checked"' : '' ); ?> value="<?php echo esc_attr( $field_val ); ?>"/>
43 + <?php endif; ?>
16 44
17 45 <input type="text" name="field_options[options_<?php echo esc_attr( $field['id'] ); ?>][<?php echo esc_attr( $opt_key ); ?>][label]" value="<?php echo esc_attr( $opt ); ?>" class="field_<?php echo esc_attr( $field['id'] ); ?>_option <?php echo esc_attr( $field['separate_value'] ? 'frm_with_key' : '' ); ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key . '-label' ); ?>" data-frmchange="trim,updateOption,checkUniqueOpt" />
18 46
19 - <a href="javascript:void(0)" class="frm_icon_font frm_remove_tag" data-fid="<?php echo esc_attr( $field['id'] ); ?>" data-removeid="frm_delete_field_<?php echo esc_attr( $field['id'] . '-' . $opt_key ); ?>_container" data-removemore="#frm_<?php echo esc_attr( $default_type . '_' . $field['id'] . '-' . $opt_key ); ?>" data-showlast="#frm_add_opt_<?php echo esc_attr( $field['id'] ); ?>"></a>
47 + <?php if ( $show_option_controls ) : ?>
48 + <a href="javascript:void(0)" class="frm_remove_tag<?php echo ! empty( $options_count ) && $options_count > 1 ? '' : ' frm_disabled'; ?>" data-fid="<?php echo esc_attr( $field['id'] ); ?>" data-removeid="frm_delete_field_<?php echo esc_attr( $field['id'] . '-' . $opt_key ); ?>_container" data-removemore="#frm_<?php echo esc_attr( $default_type . '_' . $field['id'] . '-' . $opt_key ); ?>" data-showlast="#frm_add_opt_<?php echo esc_attr( $field['id'] ); ?>">
49 + <?php FrmAppHelper::icon_by_class( 'frmfont frm_minus1_icon frm_svg15' ); ?>
50 + </a>
20 51
52 + <a href="javascript:void(0);" data-opttype="single" class="frm_cb_button frm_add_opt frm_form_field" id="frm_add_opt_<?php echo esc_attr( $field['id'] ); ?>">
53 + <?php FrmAppHelper::icon_by_class( 'frmfont frm_plus1_icon frm_add_tag frm_svg15' ); ?>
54 + </a>
55 + <?php endif; ?>
56 +
21 57 <span class="frm_option_key frm-with-right-icon field_<?php echo esc_attr( $field['id'] ); ?>_option_key<?php echo esc_attr( $field['separate_value'] ? '' : ' frm_hidden' ); ?>">
22 - <input type="<?php echo esc_attr( $default_type ); ?>" class="frm_invisible" />
58 + <?php if ( in_array( $default_type, array( 'radio', 'checkbox' ), true ) ) : ?>
59 + <input type="<?php echo esc_attr( $default_type ); ?>" class="frm_invisible" />
60 + <?php endif; ?>
23 61 <input type="text" name="field_options[options_<?php echo esc_attr( $field['id'] ); ?>][<?php echo esc_attr( $opt_key ); ?>][value]" id="field_key_<?php echo esc_attr( $field['id'] . '-' . $opt_key ); ?>" value="<?php echo esc_attr( $field_val ); ?>" placeholder="<?php esc_attr_e( 'Saved Value', 'formidable' ); ?>" data-frmchange="trim,updateDefault,checkUniqueOpt" />
24 62 <?php
25 63 if ( $show_icons ) {
26 64 FrmAppHelper::icon_by_class( 'frmfont frm_save_icon' );