Conditional Logic
Show or hide form elements based on customer input
Simply Forms team
Last Update il y a 6 jours
Conditional Logic lets you dynamically show or hide form elements based on a customer's input. By displaying only relevant fields, you can create cleaner, shorter, and more user-friendly forms.
How Conditional Logic Works
Each conditional rule consists of three parts:
- Field – The form field whose value will be evaluated.
- Operator – The comparison method.
- Value – The value to compare against.
- Show the current element, or
- Hide the current element,
| Field | Operator | Value | Result |
|---|---|---|---|
| Contact Method | equal to | Show Email Address field | |
| Rating | >= | 4 | Show "Would you like to leave a review?" |
| Purchase Type | contains | wholesale | Show Company Information section |
Supported Field Types
The left side of a rule (the field being evaluated) can currently be one of the following field types:
| Field Type | Description |
|---|---|
| Dropdown | Single option selection |
| Checkboxes | Multiple option selection |
| Radio Buttons | Single option selection |
| Rating | Numeric rating |
| Range | Numeric slider |
Supported Operators
The available operators depend on the type of value being evaluated.
String Operator
For text-based values (such as Dropdown, Radio Buttons, or Checkbox option values), Simply Forms supports the following operators. All text comparisons are case-insensitive.
| Operator | Description |
|---|---|
| contains | Field value contains the specified text |
| not contain | Field value does not contain the specified text |
| starts with | Field value begins with the specified text |
| ends with | Field value ends with the specified text |
| equal to | Exact match |
| not equal to | Values are different |
Example (Checkboxes Field)
Suppose a Checkbox field returns:
Each selected value is evaluated individually. The rule returns true if any selected value satisfies the condition.
| Rule | Result | Reason |
|---|---|---|
| Contains "Email" | True | One selected value is "Email". |
| Contains "Person" | True | "In-person" contains "Person" (case-insensitive). |
| Starts With "Ph" | True | "Phone" starts with "Ph". |
| Ends With "son" | True | "In-person" ends with "son". |
| Equal To "Email" | True | One selected value exactly matches "Email". |
| Not Equal To "SMS" | True | At least one selected value ("Phone", "Email", or "In-person") is not "SMS". |
| Contains "Fax" | False | None of the selected values contains "Fax". |
Number Operators
For numeric values (such as Rating and Range), the following operators are available:
| Operator | Description |
|---|---|
| Equal To (=) | Values are equal |
| Not Equal To (!=) | Values are different |
| Greater Than (>) | Larger than |
| Greater Than or Equal To (>=) | Larger than or equal to |
| Less Than (<) | Smaller than |
| Less Than or Equal To (<=) | Smaller than or equal to |
Example
| Rule | Results (Rating = 4) |
|---|---|
| Rating >= 4 | True |
| Rating > 4 | False |
| Rating < 5 | True |
Combining Multiple Rules
A condition can contain multiple rules. You can combine them using either AND or OR.
AND
All rules must be true.
Example: The condition is satisfied only if both of the following rules are true.
OR
Any rule can be true.
Example: The condition is satisfied if either rule is true.
Example: The condition is satisfied if either rule is true.
Using Conditional Logic with Container Elements
One of the most powerful features of Simply Forms is that Conditional Logic can also be applied to container elements, including:
- Fieldset
- Two Column Row
- Three Column Row
- Other container elements
- Company Name
- Tax ID
- Business Address
- Contact Person
If the condition is not met, the entire section remains hidden.
This approach keeps your form easier to maintain and avoids repeating the same condition on multiple elements.
This approach keeps your form easier to maintain and avoids repeating the same condition on multiple elements.
Requirement for Display Labels
All input elements that participate in form submission must have a unique Display Label across the entire form, regardless of whether they are configured to Show or Hide.
This requirement does not apply to static elements such as Fieldset, since they do not collect user input or generate submission data.
Simply Forms uses the first non-empty line of an input element's Display Label as the key when storing submitted data. To ensure each submitted value can be uniquely identified, no two input elements can have the same Display Label.
This requirement does not apply to static elements such as Fieldset, since they do not collect user input or generate submission data.
Simply Forms uses the first non-empty line of an input element's Display Label as the key when storing submitted data. To ensure each submitted value can be uniquely identified, no two input elements can have the same Display Label.
Important: If this requirement is not met, the form cannot be saved until the duplicate or missing Display Labels are corrected.
Best Practices
