namespace WPForms\Forms\Fields\Hidden;
use WPForms\Forms\Fields\Traits\ProField as ProFieldTrait;
class Field extends WPForms_Field {
* Primary class constructor.
// Define field type information.
$this->name = esc_html__( 'Hidden Field', 'wpforms-lite' );
$this->icon = 'fa-eye-slash';
$this->allow_read_only = false;
$this->default_settings = [
protected function hooks(): void {
add_filter( 'wpforms_field_new_class', [ $this, 'preview_field_new_class' ], 10, 2 );
* Field options panel inside the builder.
* @param array $field Field data and settings.
public function field_options( $field ) {
'after_title' => $this->get_field_options_notice(),
'tooltip' => esc_html__( 'Enter text for the form field label. Never displayed on the front-end.', 'wpforms-lite' ),
// Set the label to disable.
'slug' => 'label_disable',
$this->field_option( 'basic-options', $field, $args );
// Advanced options open markup.
$this->field_option( 'default_value', $field );
$this->field_option( 'css', $field );
'class' => 'wpforms-disabled',
// Advanced options close markup.
* Get a new field CSS class.
* @param string|mixed $css_class Preview new field CSS class.
* @param array $field Field data.
public function preview_field_new_class( $css_class, array $field ): string {
$css_class = (string) $css_class;
if ( empty( $field['type'] ) || $field['type'] !== $this->type ) {
return trim( $css_class . ' label_hide' );
* Field preview inside the builder.
* @param array $field Field data and settings.
public function field_preview( $field ) {
$default_value = ! empty( $field['default_value'] ) ? $field['default_value'] : '';
// The Hidden field label is always hidden.
$field['label_hide'] = '1';
$this->field_preview_option(
'label_badge' => $this->get_field_preview_badge(),
echo '<input type="text" class="primary-input" value="' . esc_attr( $default_value ) . '" readonly>';
* Field display on the form front-end.
* @param array $field Field data and settings.
* @param array $deprecated Not used any more field attributes.
* @param array $form_data Form data and settings.
public function field_display( $field, $deprecated, $form_data ) {