renderWhen on any component in your FormEngine JSON schema. The expression runs on
every state change — when it returns true the component renders; when it returns false it’s
hidden and its validations are skipped automatically.
Last reviewed: April 2026.
This tutorial covers the common patterns for showing and hiding fields based on user input in
FormEngine. The mechanism is renderWhen — an expression or function evaluated against the current
form state.
What you’ll learn: four patterns used in real forms — checkbox toggle, dropdown branch, cascading reveal, and full section toggle.
Prerequisites: FormEngine Core installed. Familiarity with the basic FormViewer setup.
FormEngine Core is open-source on GitHub. For visual
conditional logic without writing JSON, see FormEngine Designer.
How renderWhen works
renderWhen sits alongside props and validations in a component’s schema entry. When present,
FormEngine evaluates it on every state change and only renders the component when the result is
true.
- Hidden fields skip validation. If
companyNameabove isrequired, that validation is ignored while the field is hidden. No need to write conditional validation logic — hiding is enough. - Hidden fields keep their data. The value in
form.data.companyNamepersists when the field is hidden. If you need to clear it, do so explicitly (see Clearing hidden values below).
form object available in expressions:
| Path | Type | Contents |
|---|---|---|
form.data | Record<string, unknown> | Current field values |
form.errors | Record<string, unknown> | Validation errors by field key |
form.hasErrors | boolean | True if any validation error exists |
form.state | Record<string, unknown> | Custom workflow state |
form.parentData | Record<string, unknown> | Parent item data inside repeaters |
form.index | number | undefined | Current repeater item index |
Pattern 1: Checkbox toggle
Show an additional field when a checkbox is checked.required validation on phoneNumber only fires when the field is visible, so users who leave
the checkbox unchecked never see a validation error for a field they can’t see.
Pattern 2: Dropdown branching
Show different fields based on which option the user selects.Pattern 3: Cascading reveal
Show field B based on field A, and field C based on both A and B. Conditions compose naturally.hasPromoCode and promoCode hide — and the promo code value is preserved but ignored.
Pattern 4: Section toggle
ApplyrenderWhen to a container component to show or hide an entire section at once.
billingSection — including their required validations — are inactive while the container is hidden.
4. Clearing hidden values on hide
By default, hidden field values persist inform.data. If you need to clear them when a field hides, use an action on the controlling field:
companyName whenever accountType changes. Only add this if stale data in hidden
fields would cause problems — for most forms it doesn’t matter because hidden fields aren’t
submitted.
Using function conditions for complex logic
When an expression becomes hard to read, switch to a function condition withcomputeType: "function":
true or false. It has access to the full form object.
Troubleshooting
Field shows when it shouldn’t — check the expression for type coercion issues.form.data.checkbox is true (boolean), not "true" (string). Test with === true not == 'true'.
Validation fires on hidden field — this is a schema issue, not a bug. Check your renderWhen
expression — if it’s returning a non-boolean truthy value instead of true, the field may be
considered visible.
Cascading condition doesn’t update — every renderWhen evaluates independently on state change.
If field C depends on both A and B, write the full condition on C — don’t assume B’s visibility is
enough.
Cleared value immediately re-populates — if a computed property writes to the same field, the
setValues action and the computed property race. Use form.state to gate the computed property
instead.
Next steps
- Conditional logic reference — complete
renderWhenAPI documentation - Actions and events reference —
setValuesand other actions - Computed properties — derive values from other fields
- Dynamic Form from JSON tutorial — full form setup from scratch
- Inspection and data collection forms — per-Repeater-item
renderWhen, parent/root scope patterns - Workflow approval forms — conditional steps, approval routing, compliance thresholds
- Designer conditional rendering — configure
renderWhenvisually without JSON - Source code and examples — FormEngine on GitHub (MIT)