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()
You might want to filter out those properties when saving your component. Depending on the state of your condition. Please see this issue for a detailed example: https://github.com/tanthammar/tall-forms/issues/105#issuecomment-1029088173
Example 3:
Example 4:
Last updated
Was this helpful?