Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Form State Empty

Security covered Maintenance fixes only 62 sites

This module enhances Drupal's conditional form fields by allowing you to clear the value of an input element when the state of another form element changes. This is especially useful for preventing unintended data submission for fields that are hidden or toggled by other form elements.

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.

Drupal 10–11

Ask your assistant about Form State Empty

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Jun 2023
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Active

Releases

Version Type Core PHP Release date
1.1.0 Stable 10–11 Apr 18, 2025
1.0.0 Stable 8–10 Jun 14, 2023