Form rules

Use conditional rules to add or remove tags from customers, show/hide fields, set redirect URL, and much more

Kyle Weiskopf avatar
Written by Kyle Weiskopf
Updated over a week ago

Overview

If you are Batman, then the 'Rules' tab of the form builder would be considered your utility belt. This popular feature in Customer Fields is both flexible and powerful. Form rules enable you to create conditional logic for form fields, set up advanced options to streamline customer data, and take better control over the user experience.

Note: Form rules are only available on the app's 'Pro' and 'Advanced' plans.

The screenshot below shows an example of where to access form rules in the app:

Tons of flexibility and logic at your fingertips

With form rules, you can define different conditions to take actions such as:

  • Show/hide fields

  • Show/hide entire form steps

  • Add & remove tags from your customers

  • Set the value of a field

  • Require fields or make them no longer required

  • Redirect the customer to a custom URL

  • Enable/disable fields (not letting a customer complete a certain field)

  • ...and more!

πŸ’‘ Pro-tip: Use variables to create powerful logic

You can use the power of data column variables to make your form rules even more dynamic. Read more about how to utilize data column variables in rules using this help article.

Video: Use form rules to create conditional fields

As shown in the video below, consider a store that sells both retail and wholesale goods. The form on this store has a field for "Are you a wholesaler?" If the customer selects 'yes', then the form automatically displays a tax ID field and a file upload field for a reseller permit:

Understanding form rules

Rules are comprised of conditions and actions. Define condition(s) to control the trigger(s), and set up the desired action(s) which will occur if the conditions have been met. Take your typical if-then statement as an example of how this works: "If (condition), then (action)"

You can add multiple rules to any form, and each rule can have multiple conditions and/or actions. This powerful flexibility allows you to create highly personalized and effective forms for pretty much any purpose you can dream up! πŸ’ͺ

❗ Notice: Form rules will only apply when a user loads or interacts with a form, and certain actions will only take effect upon form submission. Form rules cannot be used to implement backend business logic.

Conditions

The first step with most rules is to define your condition(s). If you define multiple conditions, then you'll want to select whether 'all conditions' or 'any condition' need to be met before triggering the rule's action(s).

Conditions vary based on field type

There are many different types of fields available in the app (see details here), and as such there are certain qualifying conditions that are only available for specific types of fields.

For example, number fields (integers or decimals) will contain number-specific conditions like "greater than" or "less than", while regular text fields include conditions such as "must be longer than x characters." There are also other useful conditions for certain field types like email, which include "domain does not equal", "domain equals", and "is a valid email address", among other things:Β 

Special conditions, e.g.: "If customer is logged in..."

Conditions that are not dependent on the value of a field or data column are designated as special conditions, and these can be quite powerful. For example, there are conditions such as "customer is logged in" and "customer is not logged in", which can be used to customize your form to show different fields to users who have not signed up while hiding (or showing) other fields to logged-in customers who already have an account.Β 

You don't have to define a condition

It's helpful to know that if you do not define a condition for a form rule, then the rule's actions will automatically take effect. This is useful if you want to always trigger a certain action. For example, if you want every customer who fills out a form to be tagged with a certain tag, then you can create a form rule like the following:

Actions

Below is a list of all of the actions currently available in Customer Fields. We've also added a short description for each action to help explain what they do, along with some common use cases.

❗Note: By default, the app will automatically apply the opposite of any action you create. For example, if you create a form rule with an action to 'show' a certain field, then the app will automatically 'hide' that field unless the rule's condition(s) are met.

Show/hide field

Show or hide a certain field or field group. This action is great if you want to dynamically show or hide fields based on the values of other fields.

Enable/disable field

Enable or disable a specific field. The action of disabling a field is a way of preventing a user from filling out a field without hiding the field altogether. A disabled field will appear subdued and it will prevent user input:

Require field/make field not required

Make a certain field required or not required. Keep in mind that you can easily make a field required by enabling the "required" setting in the field validation section of the form builder (see details here) -- no form rules are needed. However, if you don't want a field to be required all of the time, then these actions allow you to control field requirements conditionally.

Set field value

Set a value for a field on the form, or for a data column that is not being used by the form. For example, assign customers from certain states or provinces to a region of your choice:

Show/hide form step

Show or hide a specific step in a form. This action is super handy for simplifying complex forms. For example, you could ask your customer for their gender on Step 1 of your form, and then when they click the "Next" button to continue, you can show them a form step that contains certain fields that are relevant to that customer's gender:

Add/remove tags from your customers

Add or remove specific tags from customers who submit the form. This action is great if you want to control specific tags without using the app's 'auto-tag' settings for fields. For example, if a "Are you a wholesaler" field equals yes, then the form will automatically add a tag of "Wholesale" to the customer in Shopify when the form is submitted.

πŸ“Œ Important notes about tag actions:

  • Comma-separated values are not supported in form rules. If you want to add or remove more than one tag at a time using form rules, then you'll need to create separate actions for each tag.

  • The app's form rules cannot remove a customer tag if the customer does not have an account. This means that if an inactive customer record has tags on file and tries to register through a Customer Fields form, any rules designed to remove tags will not get applied to the customer's record.

Redirect the customer to a custom URL

Redirect customers to a specific URL after the form is submitted. This action is great if you want to override the form's default redirect URL. You can set the default redirect URL using the 'Settings' tab in the form builder, or you can redirect users to different pages depending on specific conditions using this rule action. Read more about redirect URLs using this help article

Stop processing other rules

Stop processing other form rules. This action is not used often, but it's quite powerful for forms with advanced logic or lots of form rules. If you want a specific condition or set of conditions to stop any other rules from being processed, then you can use this action.

Disable form submission

Disable the form from being submitted. This action is great if you want to prevent customers from submitting the form altogether. We usually suggest using this rule in conjunction with a "show field" action. For example, if the customer selects that they are under 18 years of age (using a date field), then you can show a display field that explains they are too young, and you can use this action to prevent the form from being submitted.

Hide form actions and errors

Hide the form's action buttons and error messages. This action allows you to hide the action buttons ("cancel", "back", "next", and "submit") along with the form errors. These elements are shown at the bottom of the form by default. We usually suggest using this action in conjunction with the "hide field" action and the "If customer is not logged in" condition. For example, if you wanted to force customers to log in first before filling out a form, you could hide the form's input fields and form actions & errors if the customer is not already logged in.

Preview form rules

All done setting up your form rules? Use the Preview tab in the form builder to see how your rules will affect form submissions.


Do you have something to add?

We're always working on making improvements to the app's form rules, so please don't hesitate to reach out if you have a suggestion on something useful to add! πŸ€—

Did this answer your question?