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?

CommentFileSizeAuthor
#2 view-addressfield-rewrite.png284.15 KBjsacksick

Comments

kferencz91 created an issue. See original summary.

jsacksick’s picture

Category: Feature request » Support request
Status: Active » Fixed
StatusFileSize
new284.15 KB

Hi, 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.

bojanz’s picture

Title: Administrative Area Shortcode Views Display » Add a display_name setting to the Subdivision views field
Category: Support request » Feature request
Status: Fixed » Active

The CountryCode views field has a nice setting for this: display_name. But Subdivision doesn't. Let's copy the same approach.

  • bojanz committed 345dbaa on 8.x-1.x
    Issue #2954927 by jsacksick, bojanz: Add a display_name setting to the...
bojanz’s picture

Status: Active » Fixed

Done.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.