class-evf-field-address.php
1 year ago
class-evf-field-ai.php
1 year ago
class-evf-field-captcha.php
4 weeks ago
class-evf-field-checkbox.php
2 months ago
class-evf-field-color.php
4 weeks ago
class-evf-field-country.php
2 months ago
class-evf-field-credit-card.php
4 weeks ago
class-evf-field-date-time.php
4 weeks ago
class-evf-field-divider.php
2 years ago
class-evf-field-email.php
1 year ago
class-evf-field-file-upload.php
1 year ago
class-evf-field-first-name.php
1 year ago
class-evf-field-hcaptcha.php
4 months ago
class-evf-field-hidden.php
1 year ago
class-evf-field-html.php
9 months ago
class-evf-field-image-upload.php
1 year ago
class-evf-field-last-name.php
1 year ago
class-evf-field-likert.php
1 year ago
class-evf-field-lookup.php
4 weeks ago
class-evf-field-number.php
1 year ago
class-evf-field-password.php
4 weeks ago
class-evf-field-payment-authorize-net.php
4 weeks ago
class-evf-field-payment-checkbox.php
4 weeks ago
class-evf-field-payment-coupon.php
4 weeks ago
class-evf-field-payment-gateway-selector.php
4 weeks ago
class-evf-field-payment-quantity.php
4 weeks ago
class-evf-field-payment-radio.php
4 weeks ago
class-evf-field-payment-single.php
4 weeks ago
class-evf-field-payment-square.php
1 year ago
class-evf-field-payment-subscription-plan.php
4 weeks ago
class-evf-field-payment-subtotal.php
4 weeks ago
class-evf-field-payment-total.php
4 weeks ago
class-evf-field-phone.php
1 year ago
class-evf-field-privacy-policy.php
2 months ago
class-evf-field-private-note.php
1 year ago
class-evf-field-progress.php
4 weeks ago
class-evf-field-radio.php
2 months ago
class-evf-field-range-slider.php
4 weeks ago
class-evf-field-rating.php
2 months ago
class-evf-field-recaptcha.php
4 months ago
class-evf-field-repeater.php
4 weeks ago
class-evf-field-reset.php
4 weeks ago
class-evf-field-scale-rating.php
1 year ago
class-evf-field-select.php
1 year ago
class-evf-field-signature.php
4 weeks ago
class-evf-field-text.php
1 year ago
class-evf-field-textarea.php
1 year ago
class-evf-field-title.php
2 years ago
class-evf-field-turnstile.php
4 months ago
class-evf-field-url.php
1 year ago
class-evf-field-wysiwyg.php
2 months ago
class-evf-field-yes-no.php
1 year ago
payment-amount-helpers.php
4 weeks ago
class-evf-field-hidden.php
101 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Hidden text field |
| 4 | * |
| 5 | * @package EverestForms\Fields |
| 6 | * @since 3.0.0 |
| 7 | */ |
| 8 | |
| 9 | defined( 'ABSPATH' ) || exit; |
| 10 | |
| 11 | /** |
| 12 | * EVF_Field_Hidden Class. |
| 13 | */ |
| 14 | class EVF_Field_Hidden extends EVF_Form_Fields { |
| 15 | |
| 16 | /** |
| 17 | * Constructor. |
| 18 | */ |
| 19 | public function __construct() { |
| 20 | $this->name = esc_html__( 'Hidden Field', 'everest-forms' ); |
| 21 | $this->type = 'hidden'; |
| 22 | $this->icon = 'evf-icon evf-icon-hidden'; |
| 23 | $this->order = 50; |
| 24 | $this->group = 'advanced'; |
| 25 | $this->settings = array( |
| 26 | 'basic-options' => array( |
| 27 | 'field_options' => array( |
| 28 | 'label', |
| 29 | 'label_disable', |
| 30 | 'default_value', |
| 31 | 'css', |
| 32 | ), |
| 33 | ), |
| 34 | 'advanced-options' => array( |
| 35 | 'field_options' => array( |
| 36 | 'meta' |
| 37 | ), |
| 38 | ), |
| 39 | ); |
| 40 | |
| 41 | parent::__construct(); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Label disable field option. |
| 46 | * |
| 47 | * @param array $field Field settings. |
| 48 | */ |
| 49 | public function label_disable( $field ) { |
| 50 | $args = array( |
| 51 | 'type' => 'hidden', |
| 52 | 'slug' => 'label_disable', |
| 53 | 'value' => '1', |
| 54 | ); |
| 55 | $this->field_element( 'text', $field, $args ); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Field preview inside the builder. |
| 60 | * |
| 61 | * @since 1.0.0 |
| 62 | * |
| 63 | * @param array $field Field data and settings. |
| 64 | */ |
| 65 | public function field_preview( $field ) { |
| 66 | // Label. |
| 67 | $this->field_preview_option( 'label', $field ); |
| 68 | |
| 69 | // Default value. |
| 70 | $default_value = isset( $field['default_value'] ) && ! empty( $field['default_value'] ) ? $field['default_value'] : ''; |
| 71 | |
| 72 | // Primary input. |
| 73 | echo '<input type="text" value="' . esc_attr( $default_value ) . '" class="widefat" disabled>'; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Field display on the form front-end. |
| 78 | * |
| 79 | * @since 1.0.0 |
| 80 | * |
| 81 | * @param array $field Field Data. |
| 82 | * @param array $field_atts Field attributes. |
| 83 | * @param array $form_data All Form Data. |
| 84 | */ |
| 85 | public function field_display( $field, $field_atts, $form_data ) { |
| 86 | // Define data. |
| 87 | $primary = $field['properties']['inputs']['primary']; |
| 88 | |
| 89 | // For edit purpose. |
| 90 | $is_edit_entry = isset( $_GET['edit-entry'] ) && sanitize_text_field( wp_unslash( $_GET['edit-entry'] ) ) ? true : false; |
| 91 | $field_type = $is_edit_entry ? 'text' : 'hidden'; |
| 92 | |
| 93 | // Primary field. |
| 94 | printf( |
| 95 | '<input type="%s" %s>', |
| 96 | $field_type, |
| 97 | evf_html_attributes( $primary['id'], $primary['class'], $primary['data'], $primary['attr'] ) |
| 98 | ); |
| 99 | } |
| 100 | } |
| 101 |