@osforms/react evaluates the rules as the user fills out the form, so fields appear and disappear in real time.
The dashboard builder doesn’t have a conditional logic editor yet. Add rules to the field definitions in a local schema, or save them in the form’s schema with PATCH /api/v1/forms/{id}.
Structure
Each field can have oneconditionalLogic rule:
Properties
Condition Structure
Operators
For
checkbox fields, use contains with the option’s value. equals only matches when exactly that one box is ticked, and an unticked checkbox group doesn’t count as empty.
Examples
Show a follow-up field
Show a text field only when the user selects “Other” from a radio:Show a field based on NPS score
Show a question only when the NPS score is low:Multiple conditions (AND)
Show a field only if the user is a Pro customer AND has submitted before:Multiple conditions (OR)
Show a field if the user selected either “email” or “phone”:How It Works
- Conditions reference fields by ID (the
idproperty on aFormField) - Put the fields a condition depends on before the conditional field in the
fieldsarray, so people answer them first - Hidden fields are excluded from the submission: their values are not sent
- In conversational mode, hidden fields are skipped in the navigation sequence
statementfields are never included in submissions