Provides a small extension to Core's conditional form fields system. Allows the clearing of an html input element based on the state of another form element(s).
Example:
$form['field_to_empty']['#states'] = [
'empty' => [
':input[name="field_being_listened_to"]' => ['value' => '0'],
],
'visible' => [
':input[name="field_being_listened_to"]' => ['value' => '1'],
]
];
The most common usage is when a field's visibility is being toggled. You don't want the value from an invisible field to be submitted. Before the best way to handle this was to "disable" the form element. Unfortunately this prevented that element from submitting at all so you could never overwrite a previous form submission.
Supporting organizations:
Project information
Seeking new maintainer
The current maintainers are looking for new people to take ownership.Maintenance fixes only
Considered feature-complete by its maintainers.- Project categories: Developer tools
- Ecosystem: Conditional Fields
86 sites report using this module
- Created by smithmilner on , updated
Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.

