Conditions
when shows a field, section or step only while other answers say so.
A condition
{
key: "certificate_number",
type: "text",
label,
when: { field: "has_certificate", equals: true },
}
A condition names a field in the same section, or section.field for one in another.
| Test | Holds when |
|---|---|
equals | the answer is this value |
in | the answer is one of these |
includes | a ticked checkbox includes this |
filled | there is any answer |
not: true | the test does not hold |
Try it in the tutorial: Showing a field sometimes.
Combining
any holds when at least one condition does; all only when every one does. They nest.
when: {
any: [
{ field: "kind", equals: "BAR" },
{ field: "extras", includes: "WINE" },
],
}
Try it in the tutorial: Any, all and not.
Sections and steps
A section and a step take when too, naming fields as section.field. A hidden section or step is not asked, not sent, not in the review, and does not count towards progress.
{ key: "terrace", title: "Terrace", when: { field: "seating.outdoor", equals: true }, fields }
Inside a list
anyRow looks inside a list field. It holds when at least one row matches, and the condition inside names the row's own fields.
when: { field: "staff", anyRow: { field: "role", equals: "CHEF" } }
A property of the pick
property tests something about the picked option instead of its code, for an option from a dictionary that carries more than a name:
when: { field: "venue_type", property: "pricing", equals: "PER_SEAT" }
Hidden means gone
A hidden field is not asked, not sent and not in the review. whenHidden sends a value in its place, for an API that wants the key anyway: whenHidden: [] sends an empty list. keepWhenHidden: true still sends its answer while it is hidden.