| @@ -1,6 +1,43 @@ | ||
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * input[type="hidden"] template | |
| 4 | - */ | |
| 5 | -?> | |
| 6 | -<input class="jet-form-builder__field hidden-field" type="hidden" name="<?php echo $this->block_type->get_field_name( $args['name'] ); ?>" value="<?php echo $args['field_value']; ?>" data-field-name="<?php echo $args['name']; ?>"> | |
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Field Template | |
| 4 | + * input[type="hidden"] template | |
| 5 | + * | |
| 6 | + * @var \Jet_Form_Builder\Blocks\Render\Base $this | |
| 7 | + */ | |
| 8 | + | |
| 9 | +use Jet_Form_Builder\Blocks\Dynamic_Value; | |
| 10 | +use Jet_Form_Builder\Classes\Regexp_Tools; | |
| 11 | + | |
| 12 | +// If this file is called directly, abort. | |
| 13 | +if ( ! defined( 'WPINC' ) ) { | |
| 14 | + die; | |
| 15 | +} | |
| 16 | + | |
| 17 | +$this->add_attribute( 'class', 'jet-form-builder__field hidden-field' ); | |
| 18 | +$this->add_attribute( 'class', $args['class_name'] ); | |
| 19 | +$this->add_attribute( 'name', $this->block_type->get_field_name( $args['name'] ) ); | |
| 20 | +$this->add_attribute( 'data-field-name', $args['name'] ); | |
| 21 | + | |
| 22 | +/** | |
| 23 | + * We need to watch only real hidden fields. | |
| 24 | + * Not static. | |
| 25 | + * | |
| 26 | + * @see \Jet_Form_Builder\Blocks\Render\Form_Hidden_Fields::render | |
| 27 | + */ | |
| 28 | +if ( empty( $this->args['_static_value'] ) ) { | |
| 29 | + $this->add_attribute( 'data-jfb-sync' ); | |
| 30 | +} | |
| 31 | + | |
| 32 | +if ( ! jet_form_builder()->regexp->has_macro( $this->args['field_value'] ) ) { | |
| 33 | + $this->add_attribute( 'value', $this->args['field_value'] ); | |
| 34 | +} else { | |
| 35 | + wp_enqueue_script( Dynamic_Value::HANDLE ); | |
| 36 | + | |
| 37 | + $this->add_attribute( 'data-value', $this->args['field_value'] ); | |
| 38 | +} | |
| 39 | + | |
| 40 | +// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 41 | +?> | |
| 42 | +<input type="hidden" <?php $this->render_attributes_string(); ?>> | |
| 43 | +<?php // phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped | |