Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Views Bootstrap 5.5.4 — Minor update available for module views_bootstrap (5.5.4). Release: Rightup theme 1.0.3 — Minor update available for theme vartheme_bs5_rightup (1.0.3). Release: CommentOn 1.0.6 — Minor update available for module commenton (1.0.6). Release: ChatGPT Ads 1.0.3 — Minor update available for module chatgpt_ads (1.0.3). Release: Opensolr Search 5.1.3 — Minor update available for module opensolr_search (5.1.3). Release: ServiceM8 Webform Integration 1.2.1 — Minor update available for module servicem8_webform (1.2.1). Release: PostfixAdmin 1.0.0 — Initial release available for module postfix_admin (1.0.0)! Release: ip_analyser 1.0.3 — Minor update available for module ip_analyser (1.0.3). Module Revived: Swagger-PHP OpenAPI 3 documentation generator 1.0.0 — Module swagger_php updated after 10 months of inactivity (1.0.0). Security Coverage: Microsoft Azure AI — Module ai_provider_azure now has official Drupal security advisory coverage.

The module is designed for setting up Form API #States over configuration.

Installation

Install the module as you would normally install a contributed Drupal module. Visit https://www.drupal.org/node/1897420 for further information.

Configuration

  1. Go to Form States Configurations page (path /admin/structure/form-states-config).
  2. Hit 'Add Form States config' link.
  3. In 'Form ID' field put ID of a form which requires form states adjustments.
  4. In 'Form States' field add form states.
  5. Hit 'Save' button.

Example

Let's imagine user account has "Contact settings" (contact) and "Locale settings" (timezone) fields. "Administrator" (administrator) user role is only user role for which "Contact settings" and "Locale settings" fields should be shown on User Registration form. Create new Form States Configuration with next values:
- Form ID: user_register_form
- Form States:

contact:
  visible:
    :input[name="roles[administrator]"]:
      - checked: TRUE

timezone:
  visible:
    :input[name="roles[administrator]"]:
      - checked: TRUE

For more examples visit https://www.drupal.org/docs/drupal-apis/form-api/conditional-form-fields.

Notes:

1. Value for "Form States" must have a valid YAML format.
2. If it requires to add #states to nested array, for example $form['field_region']['widget']['#states'] then use field_region.widget.
3. Created configurations are exportable. Use `drush cim` to do that. Each of configuration will be exported to the config directory as form_states_config.form_states_config.[form_id].yml files.

References:

- https://www.drupal.org/docs/drupal-apis/form-api/conditional-form-fields

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
Apr 2023
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Releases

Version Type Core Release date
1.0.0-beta1 Pre-release Dec 2, 2023
1.0.0-alpha1 Pre-release Apr 13, 2023