Currently, when rendering the address/administrative_area element in a view, the full state / admin area name is displayed (ex: Ohio instead of OH). Would a formatter be possible to switch between which type of display a user may want?
Current use case:
Trying to export out a series of nodes that have an address field, broken down into individual items within the address. Exporting from the Drupal 8 view into CSV for migration purposes. The format that is needed to then migrate into Drupal is the shortcode value (ex: "OH" instead of "Ohio"), not the full name. Exporting to CSV circumvents theme templates, so can't easily override through there. Would be nice to have a formatter option directly in the view to toggle between how it should be displayed.
Possible?
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | view-addressfield-rewrite.png | 284.15 KB | jsacksick |
Comments
Comment #2
jsacksick commentedHi, I just tried it locally and it's already possible by adding your address field directly in the view (instead of the administrative area field). You can then rewrite the results and output {{ field_address__administrative_area }} instead (replace "field_address" by your own field name), and it correctly outputs the state code instead of the name.
Comment #3
bojanz commentedThe CountryCode views field has a nice setting for this: display_name. But Subdivision doesn't. Let's copy the same approach.
Comment #5
bojanz commentedDone.