| @@ -1,21 +1,48 @@ | ||
| 1 | 1 | <?php |
| 2 | +/** | |
| 3 | + * Field size (pixels wide) setting in field settings. | |
| 4 | + * | |
| 5 | + * @package Formidable | |
| 6 | + * | |
| 7 | + * @var array $field Field data including 'id' and 'size'. | |
| 8 | + * @var bool $display_max Whether to include the Max Characters input. | |
| 9 | + */ | |
| 10 | + | |
| 2 | 11 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | 12 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 13 | } |
| 14 | + | |
| 15 | +$field_size_container_atts = array(); | |
| 16 | + | |
| 17 | +if ( $display_max ) { | |
| 18 | + $max_characters_label = __( 'Max Characters', 'formidable' ); | |
| 19 | + $can_fit_label_in_two_columns = FrmAppHelper::mb_function( array( 'mb_strlen', 'strlen' ), array( $max_characters_label ) ) < 20; | |
| 20 | + | |
| 21 | + if ( $can_fit_label_in_two_columns ) { | |
| 22 | + $field_size_container_atts['class'] = 'frm6 frm_form_field'; | |
| 23 | + } | |
| 24 | +} | |
| 5 | 25 | ?> |
| 6 | -<p class="<?php echo esc_attr( $display_max ? 'frm6 frm_form_field' : '' ); ?>"> | |
| 26 | +<p <?php FrmAppHelper::array_to_html_params( $field_size_container_atts, true ); ?>> | |
| 7 | 27 | <label for="field_options_size_<?php echo esc_attr( $field['id'] ); ?>"> |
| 8 | 28 | <?php esc_html_e( 'Field Size', 'formidable' ); ?> |
| 9 | - <span class="frm-sub-label"> | |
| 10 | - <?php esc_html_e( '(%, px, em)', 'formidable' ); ?> | |
| 11 | - </span> | |
| 12 | 29 | </label> |
| 13 | 30 | |
| 14 | - <input type="text" name="field_options[size_<?php echo esc_attr( $field['id'] ); ?>]" value="<?php echo esc_attr( $field['size'] ); ?>" size="5" id="field_options_size_<?php echo esc_attr( $field['id'] ); ?>" aria-describedby="howto_size_<?php echo esc_attr( $field['id'] ); ?>" /> | |
| 31 | + <?php | |
| 32 | + FrmHtmlHelper::echo_unit_input( | |
| 33 | + array( | |
| 34 | + 'value' => $field['size'], | |
| 35 | + 'field_attrs' => array( | |
| 36 | + 'id' => 'field_options_size_' . $field['id'], | |
| 37 | + 'name' => 'field_options[size_' . $field['id'] . ']', | |
| 38 | + ), | |
| 39 | + ) | |
| 40 | + ); | |
| 41 | + ?> | |
| 15 | 42 | </p> |
| 16 | 43 | |
| 17 | 44 | <?php |
| 18 | 45 | if ( $display_max ) { |
| 19 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/max.php' ); | |
| 46 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/max.php'; | |
| 20 | 47 | } |
| 21 | 48 | ?> |