Dependent location fields¶
Version v1
You can apply this model as a recipe (Drupal 10.3 or later) to your own Drupal site:
1 2 3 4 5 6 7 8 9 10 11 | |
Purpose¶
This model provides dependent Country, State or province, and City select fields on the Location content form. Choosing a country refreshes the available states or provinces through Ajax. Choosing a state or province refreshes the available cities.
How it works¶
The form build event adds Ajax handlers to the Country and State or province fields. Each form rebuild first clears the dependent options. Conditions compare the submitted form values and then populate only the matching downstream options.
Test data¶
The compact demonstration data contains Canada, Germany, and the United States. Each country provides three states or provinces, and each state or province provides two cities. Country and subdivision keys use ISO 3166 codes where applicable.
Dependencies¶
- config
- field.field.node.location.field_city
- field.field.node.location.field_country
- field.field.node.location.field_state
- field.storage.node.field_city
- field.storage.node.field_country
- field.storage.node.field_state
- node.type.location
- module
- eca_base
- eca_form
- menu_ui
- modeler_api
- node
- options
Used plugins¶
Events¶
Conditions¶
- Country is Canada
- Country is Germany
- Country is United States
- State or province is British Columbia
- State or province is Ontario
- State or province is Quebec
- State or province is Hesse
- State or province is Bavaria
- State or province is North Rhine-Westphalia
- State or province is California
- State or province is New York
- State or province is Texas
Actions¶
- Refresh form when country changes
- Refresh form when state or province changes
- Clear state or province options
- Clear city options
- Show Canadian provinces
- Show German states
- Show United States states
- Show British Columbia cities
- Show Ontario cities
- Show Quebec cities
- Show Hesse cities
- Show Bavaria cities
- Show North Rhine-Westphalia cities
- Show California cities
- Show New York cities
- Show Texas cities
Changelog¶
Initial version