Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Usage Milestone: Decoupled Router Module decoupled_router crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Form State Empty

68 sites Security covered Drupal 10–11
View on drupal.org

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.

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
1
Tracked since
Apr 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Dormant

Releases

Version Type Core Release date
1.1.0 Stable 10–11 Apr 18, 2025