calculated-field.php
4 years ago
checkbox-field.php
4 years ago
date-field.php
4 years ago
datetime-field.php
4 years ago
form-break-field.php
4 years ago
group-break-field.php
4 years ago
heading-field.php
4 years ago
hidden-field.php
4 years ago
media-field.php
4 years ago
number-field.php
4 years ago
radio-field.php
4 years ago
range-field.php
4 years ago
select-field.php
4 years ago
submit-field.php
4 years ago
text-field.php
4 years ago
textarea-field.php
4 years ago
time-field.php
4 years ago
wysiwyg-field.php
4 years ago
text-field.php
66 lines
| 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 | |
| 11 | $this->add_attribute( 'placeholder', $args['placeholder'] ); |
| 12 | $this->add_attribute( 'value', $args['default'] ); |
| 13 | $this->add_attribute( 'required', $this->block_type->get_required_val() ); |
| 14 | $this->add_attribute( 'name', $this->block_type->get_field_name( $args['name'] ) ); |
| 15 | $this->add_attribute( 'id', $this->block_type->get_field_id( $args ) ); |
| 16 | $this->add_attribute( 'type', $args['field_type'] ); |
| 17 | $this->add_attribute( 'data-field-name', $args['name'] ); |
| 18 | $this->add_attribute( 'class', 'jet-form-builder__field text-field' ); |
| 19 | $this->add_attribute( 'class', $args['class_name'] ); |
| 20 | $this->add_attribute( 'class', $this->maybe_get_error_class( $args ) ); |
| 21 | $this->add_attribute( 'minlength', $args['minlength'] ); |
| 22 | $this->add_attribute( 'maxlength', $args['maxlength'] ); |
| 23 | |
| 24 | |
| 25 | if ( ! empty( $args['enable_input_mask'] ) && ! empty( $args['input_mask'] ) ) { |
| 26 | $this->add_attribute( 'class', 'jet-form-builder__masked-field' ); |
| 27 | |
| 28 | $mask_type = ! empty( $args['mask_type'] ) ? $args['mask_type'] : ''; |
| 29 | |
| 30 | if ( $mask_type ) { |
| 31 | $this->add_attribute( 'data-inputmask', '\'alias\': \'' . esc_attr( $mask_type ) . '\'' ); |
| 32 | $this->add_attribute( 'data-inputmask-inputformat', esc_attr( $args['input_mask'] ) ); |
| 33 | $this->add_attribute( 'data-inputmask-inputmode', 'verbatim' ); |
| 34 | } else { |
| 35 | $this->add_attribute( 'data-inputmask', '\'mask\': \'' . esc_attr( $args['input_mask'] ) . '\'' ); |
| 36 | } |
| 37 | |
| 38 | $mask_placeholder = ! empty( $args['mask_placeholder'] ) ? esc_attr( $args['mask_placeholder'] ) : ''; |
| 39 | |
| 40 | if ( $mask_placeholder ) { |
| 41 | $this->add_attribute( 'data-inputmask-placeholder', $mask_placeholder ); |
| 42 | } |
| 43 | |
| 44 | $mask_visibility = ! empty( $args['mask_visibility'] ) ? $args['mask_visibility'] : 'always'; |
| 45 | |
| 46 | switch ( $mask_visibility ) { |
| 47 | case 'focus': |
| 48 | $this->add_attribute( 'data-inputmask-showmaskonhover', 'false' ); |
| 49 | break; |
| 50 | |
| 51 | case 'hover': |
| 52 | $this->add_attribute( 'data-inputmask-showmaskonhover', 'true' ); |
| 53 | $this->add_attribute( 'data-inputmask-showmaskonfocus', 'true' ); |
| 54 | break; |
| 55 | |
| 56 | default: |
| 57 | $this->add_attribute( 'data-inputmask-clearmaskonlostfocus', 'false' ); |
| 58 | break; |
| 59 | } |
| 60 | |
| 61 | } |
| 62 | ?> |
| 63 | <div class="jet-form-builder__field-wrap"> |
| 64 | <input <?php $this->render_attributes_string(); ?>> |
| 65 | <?php echo $this->maybe_render_error( $args ); ?> |
| 66 | </div> |