PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.6
JetFormBuilder — Dynamic Blocks Form Builder v3.6.6
3.6.6.1 3.6.6 3.6.5.4 3.6.5.3 3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 All 134 releases
jetformbuilder / modules / blocks-v2 / text-field / block-template.php

block-template.php in JetFormBuilder — Dynamic Blocks Form Builder 3.6.6, at modules/blocks-v2/text-field/block-template.php

113 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * input[type="hidden"] template
4 *
5 * @var Base $this
6 * @var array $args
7 */
8
9 use Jet_Form_Builder\Blocks\Render\Base;
10 use Jet_Form_Builder\Classes\Tools;
11
12 // If this file is called directly, abort.
13 if ( ! defined( 'WPINC' ) ) {
14 die;
15 }
16
17 $this->set_value();
18 $this->add_attribute( 'placeholder', $args['placeholder'] );
19 $this->add_attribute( 'required', $this->block_type->get_required_val() );
20 $this->add_attribute( 'name', $this->block_type->get_field_name( $args['name'] ) );
21 $this->add_attribute( 'id', $this->block_type->get_field_id( $args ) );
22 $this->add_attribute( 'type', $args['field_type'] );
23 $this->add_attribute( 'data-field-name', $args['name'] );
24 $this->add_attribute( 'class', 'jet-form-builder__field text-field' );
25 $this->add_attribute( 'class', $args['class_name'] );
26 $this->add_attribute( 'minlength', $this->args['minlength'] ?? '' );
27 $this->add_attribute( 'maxlength', $this->args['maxlength'] ?? '' );
28 $this->add_attribute( 'data-jfb-sync' );
29
30 $autocomplete = $this->args['autocomplete'] ?? 'off';
31 if ( 'on' === $autocomplete ) {
32 $autocomplete_value = $this->args['autocomplete_value'] ?? 'on';
33 if ( 'custom' === $autocomplete_value ) {
34 $autocomplete_value = $this->args['autocomplete_custom'] ?? '';
35 }
36 $autocomplete = $autocomplete_value ?: 'on';
37 }
38
39 $this->add_attribute(
40 'autocomplete',
41 'off' === $autocomplete
42 ? 'off_' . substr( str_shuffle( 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' ), 0, 8 )
43 : $autocomplete
44 );
45
46 if ( ! empty( $args['enable_input_mask'] ) && ! empty( $args['input_mask'] ) ) {
47 $this->add_attribute( 'class', 'jet-form-builder__masked-field' );
48
49 $mask_type = ! empty( $args['mask_type'] ) ? $args['mask_type'] : '';
50
51 $clear = $this->args['clear_on_submit'] ?? '';
52
53 if ( $clear ) {
54 $this->add_attribute( 'data-clear-mask-on-submit', $clear );
55 }
56
57 if ( $mask_type ) {
58 $this->add_attribute( 'data-inputmask', '\'alias\': \'' . esc_attr( $mask_type ) . '\'' );
59 $this->add_attribute( 'data-inputmask-inputformat', esc_attr( $args['input_mask'] ) );
60 $this->add_attribute( 'data-inputmask-inputmode', 'verbatim' );
61 } else {
62 $this->add_attribute( 'data-inputmask', '\'mask\': \'' . esc_attr( $args['input_mask'] ) . '\'' );
63 }
64
65 $mask_placeholder = ! empty( $args['mask_placeholder'] ) ? esc_attr( $args['mask_placeholder'] ) : '';
66
67 if ( $mask_placeholder ) {
68 $this->add_attribute( 'data-inputmask-placeholder', $mask_placeholder );
69 }
70
71 $mask_visibility = ! empty( $args['mask_visibility'] ) ? $args['mask_visibility'] : 'always';
72
73 switch ( $mask_visibility ) {
74 case 'focus':
75 $this->add_attribute( 'data-inputmask-showmaskonhover', 'false' );
76 break;
77
78 case 'hover':
79 $this->add_attribute( 'data-inputmask-showmaskonhover', 'true' );
80 $this->add_attribute( 'data-inputmask-showmaskonfocus', 'true' );
81 break;
82
83 default:
84 $this->add_attribute( 'data-inputmask-clearmaskonlostfocus', 'false' );
85 break;
86 }
87 }
88 $show_eye = $this->args['showEye'] ?? false;
89 $wrap_classes = sprintf(
90 'jet-form-builder__field-wrap %s',
91 $show_eye ? 'has-eye-icon' : ''
92 )
93
94 // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
95 ?>
96 <div class="<?php echo esc_attr( trim( $wrap_classes ) ); ?>">
97 <?php do_action( 'jet-form-builder/before-field', $this ); ?>
98 <input <?php $this->render_attributes_string(); ?>>
99 <?php if ( $show_eye && 'password' === $args['field_type'] ) : ?>
100 <span
101 class="jfb-eye-icon seen"
102 role="button"
103 tabindex="0"
104 style="<?php echo Tools::is_editor() ? 'display:none;' : ''; ?>"
105 >
106 <?php echo $this->get_seen_icon(); ?>
107 <?php echo $this->get_unseen_icon(); ?>
108 </span>
109 <?php endif; ?>
110 <?php do_action( 'jet-form-builder/after-field', $this ); ?>
111 </div>
112 <?php // phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped
113