Form conditional logic

Business Professional

In this tutorial, we'll walk you through using conditional logic in forms using Gruntify.

What is Conditional Logic?

Conditional logic allows you to dynamically adjust your form based on user input. This means you can show or hide certain fields or sections of the form depending on what the user selects or enters. Conditional logic streamlines the form filling process by eliminating unnecessary fields. It ensures data validity by only presenting relevant fields to users. This makes data entry easier and more efficient. In the example below, Question 2 will only appear if a user answers “Yes” to Question 1.


Adding Conditional Logic to Your Forms

In Gruntify, it is presented as an Add If-Then statement because IF a condition is met, THEN the control appears and the field can be completed. Form conditional logic can be applied to many different form controls, but the comparisons can only be done on Dropdowns, Switches, and Segmented controls.

Step 1: Accessing Conditional Logic in Gruntify

  • Start by accessing your form in Gruntify.

  • Look for the conditional icon on the section or field where you want to apply conditional logic.

  • Click on the icon to open the Conditional Logic definition panel.


Step 2: Adding Conditions

  • In the Conditional Logic panel, click on "Add Condition".

  • Select the control or field that you want to base your condition on from the dropdown list.

  • Choose the comparison (e.g., "is", "is not", etc.).

  • Set the value for the comparison.

Step 3: Setting Up Conditions

  • Conditions are joined with an "AND" statement.

  • You can add multiple conditions by clicking the plus icon near the "Add If" heading.

  • Conditions can be removed using the minus icon.

Step 4: Applying Conditional Logic

  • Conditional logic can be applied to various control types, including Switches, Dropdowns, and Segmented controls.

  • You can remove all conditions by clearing the conditional logic on the control.

If the original fields are changed and the extra controls removed, any data in those controls is also removed.

Video Tutorial

The video tutorial below will explain how to add conditional logic in further detail. 


To make the forms easier to fill in, Gruntify suggests applying a concept of scope to the sections of a form. Should you have many conditionals on a form, your users may be left wondering why fields appear when they do and why they don’t at other times. To reduce this confusion we recommend using sections within sections so that users drill down into more and more specific sets of fields.

If you need to have fields that are used for overall control of the form, we suggest you put them in the first section of your form.

Let’s look at an example. Assume we are helping the staff at the local cafe take a dessert order. We create the form shown below.

The Conditions work as follows:

  • “Gluten Free Ice Creams” tab will only be shown when “Dairy?” is set to “Yes”.

  • “What Flavour Icecream?” is only shown when “Do you like Ice Cream?” is set to “Yes”.

  • “Choc Top with Vanilla” is only shown when “What Flavour Icecream” is set to “Vanilla”.

So, within the “Gluten Free Ice Creams” section (blue box), you should only create conditions based on fields in the “Gluten Free Ice Creams” section and the first section, the green box. But nothing from the “Cakes and Puddings” section (red box).

  • “Gluten Choices” is only shown when “Gluten-Free Needed” is set to “No”.

  • “Christmas Pudding” is only shown when “Temperature” is set to “Hot”.

  • “Double Choc Mud Cake” is only shown when “Temperature” is set to “Cold”.

So, within the “Cakes and Puddings” section (red box), you should only create conditions based on fields in the “Cakes and Puddings” section and the first section, the green box. But nothing from the “Gluten Free Ice Creams” section (blue box). Gruntify may allow you to select some fields from the blue box but we suggest that you think very carefully before using them. It may cause confusion for your users.

But what if you wanted to, say, show the “Acai Berry Surprise” if they have already said that they like ice cream? Replace the current “Dairy?” question with “Do you like Ice Cream?”, and then the “Gluten Free Ice Creams” tab becomes simpler (see below).


If you want to give this form a try in your workspace, download the file below and import using the Import option on the main Form manager screen.

Advanced Topic: Complex Conditionals

This description is for advanced form users who want to push the boundary of what is possible. The description of what you should do with a Gruntify form is given above. Forms written using this advice should always work.

In general, controls can have a condition based on any control (with the exclusions below) that exists in a previous section. So in the example given above, the “Acai Berry Surprise” can actually be based on the “Do you like Ice Cream?” from Section 2 currently. We recommend against it as it can make things confusing, but you can do it. This is not likely to change in the future.

At present, controls can have a condition based on some controls that exist in following sections. This is likely to change in the future and you should avoid developing a form that way. It is very confusing for a user to change a value on section 5 of a form, and then have to go back to Section 2 and change values there due to a condition change. Forms should work in a simple linear forward order as much as possible.

To stop you from creating a form with loops, which will be impossible for users to fill out properly the following controls are excluded from the Conditional drop-down list:

  • Controls with conditions that directly reference the control being edited are excluded.

  • Controls with conditions that indirectly reference the control being edited are excluded. Example:

    • We're editing control A

    • Control B has a condition that references control A. Control B will be excluded.

    • Control C has a condition that references control B. Control C will be excluded.

  • When a section has a condition that references the control being edited (directly or indirectly), all controls inside that section are excluded.

  • Controls with conditions that reference controls inside an excluded section will be excluded.

  • Basically, and control with conditions (including its parent sections) that directly or indirectly references the selected control should be excluded, so it should not be possible to create conditional loops (A depends on B, depends on C, depends on A).