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.
Scope
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.
Related articles