Conditional Logic in React Forms
Conditional logic is what turns a static form into a dynamic one. It lets you show, hide, or adapt fields based on what the user has already entered. In FormEngine, this behavior lives in the schema instead of inuseState, watch, and conditional JSX branches.
If you want dynamic React forms without a lot of component-level wiring, this page is the core reference.
How conditional logic works in FormEngine
The main mechanism isrenderWhen.
When a component has renderWhen, FormEngine checks the condition against the current form state and renders the component only when the result is true.
This gives you a schema-driven way to build:
- progressive disclosure
- optional sections
- dependent fields
- dynamic wizard flows
Quick example
Show a company field only when the selected account type is business:Conditional field
Real working example from the FormEngine examples
The communitySampleForm.json uses real conditional rendering to switch between success and error messages after validation:
Success and error visibility from SampleForm.json
renderWhen values after the runtime validation result is known:
showValidationResult action from the same example
- validation state
- action chains
- runtime component store updates

What renderWhen can access
Conditions run with access to the form object:
| Path | What it provides |
|---|---|
form.data | current form values |
form.errors | current validation errors |
form.hasErrors | whether the form has errors |
form.state | shared workflow state |
form.parentData | parent item data inside repeaters |
form.rootData | root-level form data |
form.index | current index inside repeaters |
form.data.
Expression-based conditions
UserenderWhen.value for short conditions:
Simple expression
Combined condition
Function-based conditions
For more complex logic, usecomputeType: "function" and fnSource:
Function-based condition
- the condition is too long for a one-line expression
- you need calculations
- multiple values must be checked together
Common patterns
Show a field from a checkbox
Checkbox-driven conditional field
Show different fields from a selected option
Payment method switch
Show help or warnings from validation state
Error-based helper content
Conditional logic and validation
This is one of the most important practical details: when a field is hidden byrenderWhen, its validation rules do not block submission.
That means you can safely make a conditionally visible field required without worrying that it will fail validation while hidden.
Use this together with validation to build:
- optional business sections
- conditional billing fields
- step-specific required fields
- gated follow-up questions
What happens to hidden field values
By default, FormEngine preserves the last value of a field even when the field becomes hidden. That is often useful, but not always. If you want hidden values cleared, trigger a reset or update action from the controlling field and keep the data model explicit. Use actions and events when you need that level of control.Conditional logic in the Designer
If your team uses the Designer, conditional logic can also be configured visually. That gives teams a path from dynamic schema rules to visual editing without changing the underlying model. See Designer conditional rendering for the builder-specific workflow.FormEngine vs manual React conditional fields
The main difference is where the logic lives:| Approach | Where conditions live | Typical cost |
|---|---|---|
| Manual React implementation | component state and conditional JSX | more wiring as the form grows |
| FormEngine | JSON schema via renderWhen | easier reuse and cleaner form definitions |
- forms have many branching paths
- fields depend on previous answers
- the same workflow appears across multiple screens or products
- teams want a visual builder later
FAQ
Can I use conditional logic on wizard steps too?
Can I use conditional logic on wizard steps too?
Yes. You can apply conditional logic to larger sections and step-like structures, not only to individual input fields.
Should I use expressions or function-based conditions?
Should I use expressions or function-based conditions?
Use expressions for short readable rules. Use functions when the condition needs calculations or would be too long in one line.
Does hiding a field also stop its validation?
Does hiding a field also stop its validation?
Yes. Hidden fields do not block submission through their validation rules.
Can I disable a field instead of hiding it?
Can I disable a field instead of hiding it?
Yes. For that pattern, combine conditional logic with computed properties or other schema-driven state control.
Next steps
Read validation
Combine conditional fields with schema-driven validation.
Use computed properties
Derive field values and UI state from other data.
Build a multi-step form
Apply conditional logic in a longer workflow.
Try it in the Online Builder
Configure dynamic field behavior visually.