Conditional Fields & Sections
Add a condition to any field, section, or signer slot to show or hide it based on earlier answers. When there's no condition, the element is always visible.
The condition model
{
"condition": {
"match": "all",
"rules": [
{ "field": "favorite_color", "operator": "EQUALS", "value": "other" }
]
}
}| Property | Type | Default | Description |
|---|---|---|---|
condition.match | "all" | "any" | "all" | "all" = every rule must pass (AND). "any" = at least one (OR). |
condition.rules | array | — | One or more rules to evaluate. |
Each rule:
| Property | Type | Required | Description |
|---|---|---|---|
field | string | yes | The name of another field. Must appear before this element in form order. |
operator | string | yes | One of the operators below. |
value | string | number | null | depends | Required for every operator except IS_EMPTY and IS_NOT_EMPTY. |
Operators
Which operators a rule can use depends on the referenced field's type:
| Operator | Meaning | Field types |
|---|---|---|
EQUALS | Matches exactly. For CHOICE: the option is among the selected values. | TEXT, NUMBER, DATE, DATETIME, CHOICE, EMAIL, PHONE |
NOT_EQUALS | The opposite of EQUALS. | TEXT, NUMBER, DATE, DATETIME, CHOICE, EMAIL, PHONE |
GREATER_THAN | Greater-than comparison (numeric or date). | NUMBER, DATE, DATETIME |
LESS_THAN | Less-than comparison (numeric or date). | NUMBER, DATE, DATETIME |
IS_EMPTY | The field has no answer. | TEXT, NUMBER, DATE, DATETIME, CHOICE, EMAIL, PHONE, NIN, BUSINESS_ID, FILE |
IS_NOT_EMPTY | The field has any answer. | TEXT, NUMBER, DATE, DATETIME, CHOICE, EMAIL, PHONE, NIN, BUSINESS_ID, FILE |
Rules
- A rule's
fieldmust reference a field that appears before the conditional element in form order. Field conditions can reference earlier fields in the same or a prior section; section conditions can only reference fields from prior sections. - Conditions chain: if B depends on A and C depends on B, hiding A cascades to both.
required: truewith aconditionmeans "required when visible". While hidden, the requirement is ignored.
Example: show a field when "Other" is selected
{
"sections": [
{
"title": "Your Preferences",
"fields": [
{
"type": "CHOICE", "name": "favorite_color", "label": "Favorite color", "required": true, "layout": "RADIO",
"options": [
{ "label": "Red", "value": "red" },
{ "label": "Blue", "value": "blue" },
{ "label": "Other", "value": "other" }
]
},
{
"type": "TEXT", "name": "color_specify", "label": "Please specify", "required": true,
"condition": { "rules": [ { "field": "favorite_color", "operator": "EQUALS", "value": "other" } ] }
}
]
}
]
}color_specify appears only when "Other" is selected, and is required when visible.
Example: a conditional section
A whole section (and its fields) can be hidden based on a field in a prior section:
{
"sections": [
{
"title": "General",
"fields": [
{
"type": "CHOICE", "name": "has_allergies", "label": "Do you have any allergies?", "required": true, "layout": "RADIO",
"options": [ { "label": "Yes", "value": "yes" }, { "label": "No", "value": "no" } ]
}
]
},
{
"title": "Allergy Details",
"condition": { "rules": [ { "field": "has_allergies", "operator": "EQUALS", "value": "yes" } ] },
"fields": [
{ "type": "TEXT", "label": "Please describe your allergies", "required": true, "multiline": true }
]
}
]
}Signer slots inside additionalSignersConfig accept a condition in the same way.
Updated 4 days ago
