Conditional field
You can display a field based on a condition.
Only null
or a Field instance, are allowed conditional values!
null
or a Field instance, are allowed conditional values!Example 1:
Example 2:
If the field depends on third party javascript libraries like FlatPickr (DatePicker field) or Trix.
You cannot switch visibility because the JS instance won't be destroyed, or the external script won't be loaded if the condition is false.
The way around it is to add class hidden
to the field-root.
Observe:
When hiding fields with class hidden
, the data properties will always exist in $form_data
and $validated_data
This is important in onCreateModel()
and onUpdateModel()
Example 3:
Example 4:
Last updated
Was this helpful?