Celebrate WordCamp Europe - 30% OFF! Use coupon WC30 - View Details

How Hidden Fields Work

Sometimes in a WordPress form you will want to hide a field value. There can be many reasons for this, including:

  • Hiding a field that contains a value that doesn’t need to be seen by the user, e.g. a tracking value.
  • Hiding a field based on the answer of another field on the form, e.g. Show an “Other” option for a Select field.
  • Hiding fields contained within a tab or a section.

Fundamentally there are two different ways of hiding field values:

  1. Use the Hidden field type.
  2. Hide a different field type (e.g. a Text field) using the Hidden setting or by using Conditional Logic.

The Hidden Field Type

If you have a form field value that should never be seen by the end user, you should use a Hidden field. You can find the Hidden field type in the Advanced grouping in the Toolbox, or use the search feature at the top of the Toolbox to search for it.

WS Form - Toolbox - Advanced - Hidden Field Type

The hidden field type is different from other hiding other field

Learn more:

Hiding Other Field Types

For fields other than the Hidden type (e.g. Text), you can use the Hidden field setting to hide the field on the form.

WS Form - Field Settings - Hidden

An example use case of using the Hidden setting would be to hide an “Other” text field for a Select field.

The default behavior of a field that has been hidden, is that it will not be included in actions such as Send Email. You can override this behavior by checking the Always Include in Actions setting (See below).

When a field is hidden, WS Form will automatically make the field no longer required. Also any other restrictions such as min and max setting are ignored. This ensures the fields are no longer validated when the form is submitted.

Using Conditional Logic to Hide & Show Fields

Any field types (other than the Hidden field type) can be hidden and shown using conditional logic. You can hide and show the field itself, the section the field is in or the tab the field is in.

When hiding a section, all fields within that section will be hidden.

When hiding a tab, all sections within that tab and their fields will be hidden.

An example condition that hides a field is shown below.WS Form - Conditional Logic - Show / Hide Field (IF [Field 1] [Row Checked] Other THEN [Field 2] [Set Visibility] Visible ELSE [Field 2] [Set Visibility] Not Visible

The default behavior of a field that has been hidden using conditional logic, is that it will not be included in actions such as Send Email. You can override this behavior by checking the Always Include in Actions setting (See below).

Including Fields That Have Been Hidden in Actions

Fields can be hidden by using the Hidden field settings or by using Conditional Logic.

By default when a form is submitted and actions such as Send Email run, WS Form will exclude any fields that have been hidden. The same applies to any fields in a hidden tab or hidden section.

You can override this behavior by using the Always Include in Actions setting on a field. To apply this setting:

  1. Click on the field settings icon.
  2. In the Basic tab, go to the Hidden Behavior setting.
  3. Check the Always Include in Actions setting.
  4. Click Save & Close.

WS Form - Field Settings - Always Include in Actions

Once checked, the field value will always be included when the form is submitted and WS Form processes the form actions, regardless of whether the field is hidden or visible.