Skip to main content

Using Field Rules

Set up conditional logic and dynamic behavior in your forms using triggers, conditions, and actions.

Updated this week

Form field rules customize how forms behave based on user input and specific conditions. This guide explains how to create and manage rules in Formulayt, including setting up dependencies between fields and configuring dynamic form behavior. When creating and editing form fields, Formulayt provides you with a powerful rule engine to tailor behavior and functionality.

Creating a rule

Rules are only created and applied to fields.

To create a rule click on the Rules tab when editing a field.

Then click on the Add new rule button.

Remember to give your rule a name which describes its function. This will help if you need to find or edit the rule later.

Triggers

Firstly, you will need to select when the rule will run. You select your trigger using the option "Run this rule:" and the value you choose should be based on the overall objective of the rule.

Rules can be run at different points in the form lifecycle:

  • Form Load: Rules run before the form displays to users

  • Continuously: Rules run in real-time as users interact with the form

  • Form Submission: Rules run after the user clicks submit (and the form has passed validation) but before the data is sent

When to use each trigger type

  • Form Load rules:

    • Run at the very beginning, before the form displays

    • Work best with gate attributes or pre-populated data

    • Cannot react to user input since they run before users interact with the form

  • Form Submission rules:

    • Run between when the user hits submit and data being sent to the receiving platform

    • Ideal for making last-minute changes to form data

    • Can populate hidden fields based on submitted information

  • Continuous rules:

    • Run in real-time as users interact with the form

    • Best when users need to see immediate effects of their input

    • Useful for showing/hiding fields based on user selections

Conditions and actions

Next you can build out the rule itself. The rule builder has 3 main sections:

  1. IF these conditions are true

  2. THEN perform these actions

  3. OTHERWISE perform these actions

When building out the first section (conditions) you can use a combination of Conditions, OR Groups and AND Groups. Conditions can be placed inside groups and groups can be nested inside each other (up to 3 levels deep) to create complex boolean logic.

Boolean groups can be switched between being an AND or an OR group by clicking on their toggle. Conditions can be duplicated by clicking on the duplicate icon and deleted by clicking on the trash icon.

It is also possible to drag a condition to another part of the rule e.g. into another boolean group.

Note: when adding multiple conditions to the root position, they will automatically be placed inside an AND group.

Condition types

When adding a Condition you can select from Form field or Gate attribute.

Form fields are the fields you have defined in the Fields area of Formulayt. Gate attributes are values that are built into Formulayt and are contained within each gate e.g. Gate name.

Once you have selected which field or attribute the condition should use, you can then add your criteria. The following criteria types can be used:

  • equals

  • does not equal

  • contains - (for partial match of text)

  • does not contain - (for partial match of text)

  • is in - (provide a list of options to match against)

  • is not in - (provide a list of options to match against)

  • is empty

  • is not empty

  • is greater than - (only applies if values are numeric)

  • is less than - (only applies if values are numeric)

  • matches regular expression - (for complex matching, requires knowledge of regular expressions)

  • doesn't match regular expression - (for complex matching, requires knowledge of regular expressions)

Note: if the field or attribute you have chosen correlates to a drop down list of values, you will be given that list to choose from in your criteria. Otherwise the criteria will be free text.

When working with "is in" and "is not in" criteria you can build a list up by pasting in comma separated values or typing each value and hitting return after each entry.

Note: in a standard Formulayt configuration, when building criteria for the country field you should use 2-digit ISO values for each country (as shown above).

Actions

Once you have built your criteria you can define your actions. You can add as many actions to a rule as you wish. The following action types are supported:

  • Show this field

  • Hide this field

  • Change this field's picklist options - (only Picklist and Radio Button Group fields)

  • Change the label of this field

  • Reset the label of this field back to original value

  • Change the placeholder of this field

  • Reset the placeholder of this field back to original value

  • Change the value of this field

  • Clear any value from this field

  • Disable this field

  • Enable this field

  • Make this field mandatory

  • Make this field optional

Note: The actions are only applied to the field you are editing. Conditions can examine any field but they cannot change the state of other fields.

In addition these rules are applied at form/gate level:

  • Open the gate immediately

  • Change the form's submit button text

  • Reset the form's submit button text back to original value

  • Override form submission destination - (only in some subscription levels)

Note: Actions performed in rules will override settings found in manage form types e.g. field visibility or mandatory status.

Otherwise actions

You can add actions when your criteria is:

  • TRUE ("Then perform these actions:")

  • or NOT TRUE ("Otherwise, perform these actions:")

CAUTION: we advise using Otherwise (NOT TRUE) actions with care:

  • Otherwise rules can catch all situations where your criteria doesn't apply

  • Using multiple Otherwise actions on a single field (i.e. multiple rules) can create overlapping logic which can create odd effects

  • If you are adding multiple rules to a field it is better to build out all criteria as rules and only use positive actions (i.e. "Then perform these actions:")

  • If there is only one rule on a field it is safer to use Otherwise actions

Example rule setup

Here's an example of creating a conditional checkbox that only appears for specific countries:

  1. Create a form field and select checkbox from the field type dropdown and configured the rest of the basic settings

  2. Click on the Rules tab, click Add new rule, and give the rule a name

  3. Set the trigger to continuous for real-time form adaptation

  4. Add a condition: Form field > country > equals > us

  5. Set the actions:

    • THEN: Hide this field

    • OTHERWISE: Show this field

  6. The resultant rule will dynamically hide the checkbox whenever the user's country is the United States, otherwise the checkbox will be shown.

Picklists (dropdown fields)

You can also manipulate the values in picklists with rules. One of the use cases for this type of rule is to create hierarchical drop down e.g. Industry and Sub-industry.

  1. Add options individually:

    • Click Add an option

    • Enter a value (the value sent to your receiving platform)

    • Enter a label (visible to the user)

  2. Bulk edit the options:

    • Click Bulk edit options

    • Update the list in the text area

    • Separate value and label with a pipe "|"

      Value|Label
      Value|Label
      Value|Label

Working with multiple rules

When using multiple rules on the same field, remember that rules run in order. The last rule that runs will take precedence over earlier rules.

Did this answer your question?