- Issue created by @kuntal_d
- Status changed to Closed: won't fix
over 1 year ago 11:15am 7 October 2023 - 🇷🇸Serbia bojanz
I can't know what's wrong, and you've provided no information that I can act on. All I can suggest is re-reading the documentation and repeating the steps mentioned there.
- Status changed to Active
about 1 year ago 7:18pm 19 January 2024 I have the same need of adding counties as well as states. I have reviewed the link included in the description of this issue and based on that documentation it looks to me like they are describing how to modify the administrative_area subfield, not add a new subfield, which is what I need.
How would I go about adding a county subfield?
- 🇷🇸Serbia bojanz
I misunderstood the request when I first closed this issue.
Unfortunately, Address has no designated property for US counties (Google calls it `administrative_area_level2`), it's not a use case we support. Adding a new property from outside the module would be impossible, you'd have to essentially fork the entire module codebase. A workaround is needed: repurposing an existing property.
We have two possible ways to achieve this:
1) Repurpose address_line3 to hold the county.
Implement a hook_field_widget_form_alter() + #after_build for the address element, which looks at the currently selected country, and if it's US, converts address_line3 to a dropdown, gives it a new label, and populates the options based on the administrative area.2) Repurpose the locality field to hold the county, and move the City to the dependent_locality field.
This allows you to use SubdivisionEvent to define the counties per administrative area, and it will just work. An alter is only needed to adjust the labels. However, you need to teach all other code (payment gateways, shipping methods) to pass $address->getDependentLocality() instead of $address->getLocality() for the city.
You also need an AddressFormatEvent to add the %dependentLocality to the format. - 🇺🇸United States dalemoore
I was exploring this module and discovered it didn't support U.S. counties as well. This would be a great feature for using the module for local, regional, and state entities as well as some university units like where I work. A lot of our work is county-based at land-grant university Extension services. It would also be useful for sites related to voting, as people are restricted to only voting within their specific state, county, and city. County is missing in that scenario here.