Conditional Logic
Fields can be conditionally shown or hidden based on the values of other fields. This lets you build dynamic forms that adapt in real time as the respondent fills them out.
FIELD_CONDITIONAL_VISIBILITY feature flag to be enabled in your config/filaforms.php.Visibility Modes
Each field has a visibility mode that controls its default state and how conditions affect it.
| Mode | Behavior |
|---|---|
ALWAYS_VISIBLE | Field is always shown (default) |
SHOW_WHEN | Field is hidden by default, shown when conditions are met |
HIDE_WHEN | Field is visible by default, hidden when conditions are met |
Conditions
A condition references a target field by its field code, an operator, and an expected value. You can attach multiple conditions to a single field.
Each condition is defined by three properties:
| Property | Description |
|---|---|
field_code | The code of the field to watch |
operator | The comparison operator to apply |
value | The expected value to compare against (not required for is_empty and is_not_empty) |
Operators
FilaForms provides 8 comparison operators.
| Operator | Description |
|---|---|
equals | Exact match. Case-insensitive for strings. |
not_equals | Not an exact match. |
contains | Substring match for strings, element check for arrays. |
not_contains | Opposite of contains. |
greater_than | Numeric comparison. Returns false for non-numeric values. |
less_than | Numeric comparison. Returns false for non-numeric values. |
is_empty | Field has no value (null, empty string, or empty array). No comparison value needed. |
is_not_empty | Field has a value. No comparison value needed. |
Operator Compatibility by Field Type
Not all operators work with all field types. The table below shows which operators are available for each data type.
| Field Data Type | Compatible Operators |
|---|---|
| STRING, TEXT | equals, not_equals, contains, not_contains, is_empty, is_not_empty |
| NUMERIC, FLOAT, DATE, DATE_TIME | equals, not_equals, greater_than, less_than, is_empty, is_not_empty |
| BOOLEAN | equals, is_empty, is_not_empty |
| SINGLE_CHOICE | equals, not_equals, is_empty, is_not_empty |
| MULTI_CHOICE | contains, not_contains, is_empty, is_not_empty |
Logic Modes
When a field has multiple conditions, a logic mode determines how they combine.
| Logic Mode | Behavior |
|---|---|
ALL (AND) | All conditions must be met for the result to be true |
ANY (OR) | Any single condition being met is enough for the result to be true |
Cascading Visibility
Visibility cascades through field dependencies. If Field B depends on Field A, and Field A is hidden because its own conditions are not met, then Field B is also hidden automatically -- regardless of whether Field B's own conditions are satisfied.
The system builds a dependency graph and recursively evaluates parent fields before evaluating a child field.
Always Save Option
By default, hidden fields are excluded from submission data. When alwaysSave is enabled on a field's visibility configuration, the field's value is saved to the submission even when the field is not visible.
This is useful when you need to preserve data that was entered before a field became hidden.
How It Works Client-Side
Conditional visibility runs entirely in the browser using Alpine.js. The AlpineVisibilityGenerator service translates each field's visibility rules into JavaScript expressions that are passed to Filament's visibleJs method. No page reload is needed -- fields appear and disappear instantly as the respondent interacts with the form.
The same evaluation logic runs on the backend during submission processing, so visibility is always consistent between what the user sees and what gets saved.
Example
A common use case: show a "Company Name" text field only when a "Type" select field equals "business".
In the form builder:
- Add a Select field with code
typeand options "Personal" and "Business" - Add a Text field with code
company_name - On the
company_namefield, open the visibility settings - Set the visibility mode to Show when conditions are met
- Add a condition: field
type/ operatorequals/ valueBusiness
The company name field will remain hidden until the respondent selects "Business" from the type dropdown.