Skip to main content

Form condition rules

In this article, we explain rules that can be used in forms to hide and calculate components.

L
Written by Lucy Robbie
Updated over 2 weeks ago

You can use conditional expressions to show or hide form components based on the value of another component. This helps tailor the form experience based on user input.

Example

We need to hide the component Details of support required, if the value of the question Standing is Independent or if the question Standing has not been answered.

From example

Each form component has a unique ID. You’ll use this ID to write expressions.

  • Standing = form_component_142

  • Details of support required = form_component_163

To hide Details of support required, use one of the following:

  1. If Standing is Independent
    (form_component_142 = "Independent")

  2. If Standing is NOT Support Required
    (form_component_142 != "Support Required")

📌 Note: Values like "Independent" are case sensitive and must match exactly what’s in the form designer.


Best practice

Here are a few tips to help you get the best out of your form conditional rules.

Do

  • Use !form_component_X?has_content to check if a field has a value.

  • Double-check your syntax—small typos can break functionality.

  • Hide entire sections instead of individual fields for better performance.

Don't

  • Try to hide fields inside tables, this won’t work.

  • Leave trailing spaces in dropdown, radio, checkbox, or multi-select options, spaces are treated as characters.


Conditional reference table

📌Note: The examples in this table use placeholder component IDs and values from a sample form. Replace the example component IDs and values with those from your own form.

Hide rules

Scenario

Rule

Outcome

Hide form_component_2 if form_component_1 has content

(form_component_1?has_content)

Field is hidden when form_component_1 has a value

Hide form_component_2 if form_component_1 has NO content

(!form_component_1?has_content)

Field is hidden when form_component_1 is empty

Hide form_component_2 if form_component_1 has some value

(form_component_1?has_content)

Field is hidden when form_component_1 has a value

Hide form_component_2 if form_component_1 doesn’t have a value

(!form_component_1?has_content)

Field is hidden when form_component_1 is empty

Hide form_component_2 if form_component_1 is NOT equal to Yes

(form_component_1 != "Yes")

Field is hidden when value is not "Yes"

Hide a component if one of two conditions is true (OR)

(form_component_1 = "Yes") || (form_component_2 = "No")

Field is hidden if either condition is true

Hide a component if multiple OR conditions are true

(!form_component_1?has_content) || (form_component_1 = "Annual Review") || (form_component_1 = "Ad-hoc Full Review")

Field is hidden if any of the conditions are true

Hide a component if both conditions are true (AND)

(form_component_1 = "Yes") && (form_component_2 = "No")

Field is hidden only if both conditions are true

Check if a checkbox component is not empty and does not contain a specific value

(!(form_component_1?has_content) || (!form_component_1?contains("a")))

Returns true if the field is empty or does not include "a"

Show a field if Other is selected in a checkbox

(!(form_component_78?has_content) || !(form_component_78?contains("Other")))

Field is hidden unless Other is selected in Risk Details

Calculate rules

Scenario

Rule

Outcome

Calculate total score from 4 days

(form_component_1 + form_component_2 + form_component_3 + form_component_4)

Returns the sum of all day scores

Divide one component by another

(form_component_1 / form_component_2)

Returns the result of division

Multiply two components

(form_component_1 * form_component_2)

Returns the result of multiplication

Assign numerical value to dropdown option 'Requires improvement'

[#elseif form_component_2 = "Requires improvement"]
[#assign form_component_2 = 5]

Assigns value 5 to the selected option

Assign numerical value to dropdown option 'Meets expectations'

[#elseif form_component_2 = "Meets expectations"]
[#assign form_component_2 = 10]

Assigns value 10 to the selected option

Assign numerical value to dropdown option 'Exceeds expectations'

[#elseif form_component_2 = "Exceeds expectations"]
[#assign form_component_2 = 15]

Assigns value 15 to the selected option

Assign numerical value to dropdown option 'Outstanding'

[#elseif form_component_2 = "Outstanding"]
[#assign form_component_2 = 20]

Assigns value 20 to the selected option

Calculate total score from multiple components

${(form_component_2 + form_component_3 + form_component_4 + form_component_6)}

Displays the total score

Assign outcome if score is missing

[#if !form_component_1?has_content]
[#assign form_component_1 = "No outcome Calculated"]

Displays "No outcome Calculated"

Assign outcome if score ≤ 200

[#elseif (form_component_1 <= 200)]
[#assign form_component_1 = "Unsatisfactory"]

Displays "Unsatisfactory"

Assign outcome if score between 201 and 300

[#elseif ((form_component_1 > 200) && (form_component_1 <= 300))]
[#assign form_component_1 = "Improvement needed"]

Displays "Improvement needed"

Assign outcome if score between 301 and 400

[#elseif ((form_component_1 > 300) && (form_component_1 <= 400))]
[#assign form_component_1 = "Fully Successful Performance"]

Displays "Fully Successful Performance"

Assign outcome if score between 401 and 550

[#elseif ((form_component_1 > 400) && (form_component_1 <= 550))]
[#assign form_component_1 = "Superior Performance"]

Displays "Superior Performance"

Assign outcome if score between 551 and 600

[#elseif ((form_component_1 > 550) && (form_component_1 <= 600))]
[#assign form_component_1 = "Distinguished Performance"]

Displays "Distinguished Performance"

Assign fallback outcome

[#else]
[#assign form_component_1 = "No Score Calculated"]

Displays "No Score Calculated"

Round BMI calculation to one decimal place

((form_component_1 / ((form_component_2 / 100) * (form_component_2 / 100)))?string("0.#"))

Returns BMI rounded to one decimal place

Did this answer your question?