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.
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!
Note: Form rules are only available on the app's "Pro" and "Advanced" plans.
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 your condition(s) to control the trigger(s), and set up the desired action(s) which will occur if your conditions have been met.
You can add multiple rules to any form, and each rules can have multiple conditions and actions. This powerful flexibility allows you to create highly personalized and effective forms for pretty much any purpose you can dream up! 💪
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.
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
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 a 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:
❗Important note about actions
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.
Below is a list of all of the actions currently available in Customer Fields. We've also added a short description for the actions to help explain what they do and some common use-cases.
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 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. Of course you can always make a field required by enabling the "required" setting in the field validation section of the form builder (see details here). However, if you don't want a field to be required for certain customers, then these actions allow you to customize those requirements dynamically.
Set field value
Set a value for a field on the form, or for 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 submitting 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 tag of "Wholesale" to the customer in Shopify when the form is submitted.
Redirect the customer to a custom URL
Redirect customers to a specific URL after the form is submitted. This action is great of 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 step 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 login 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.
➡️ 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.
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! 🤗