drupal-eca-recipe / eca_lib_0040
Provides a Location content type with dependent Country, State or province, and City select fields. ECA adds Ajax handlers and populates the downstream options from a compact demonstration data set.
Package info
gitlab.lakedrops.com/drupal/recipes/eca_lib_0040
Type:drupal-recipe
pkg:composer/drupal-eca-recipe/eca_lib_0040
Requires
- drupal/eca: *
- drupal/modeler_api: *
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
ID: eca_lib_0040
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.
Installation
## Import recipe
composer require drupal-eca-recipe/eca_lib_0040
# Apply recipe with Drush (requires version 13 or later):
drush recipe ../recipes/eca_lib_0040
# Apply recipe without Drush:
cd web && php core/scripts/drupal recipe ../recipes/eca_lib_0040
# Rebuilding caches is optional, sometimes required:
drush cr