Multiple value Address field in views always shows first item subdivision name

Created on 12 November 2020, over 3 years ago
Updated 29 May 2024, about 1 month ago

When "Display the subdivision name instead of the subdivision code" is enabled for multi-value address field, views renders first item value for all items.

I believe the problem is in line 91 of src/Plugin/views/field/Subdivision.php

$address = $entity->{$this->definition['field_name']}->first();

I guess we need something like this
$address = $entity->{$this->definition['field_name']}->get($index);

but have no idea how to get the $index value.

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡§πŸ‡¦Bosnia and Herzegovina nno

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡·πŸ‡ΈSerbia bojanz

    Are we sure this works when there are multiple subdivision fields in the same view? For example, both administrative_area and locality for a country such as Brazil?

    I am asking cause we're using $values->delta to get the delta, but Views likes to append a counter to the field alias if one is already in use. In which case something like $values->{$this->aliases['delta']} might be needed.

  • This issue is occurring on the 2.0 brach as well. When I looked at the code it was not updated. I'm not a developer can we get a patch?

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.x + Environment: PHP 8.2 & MySQL 8
    last update about 1 month ago
    43 pass
  • πŸ‡ΊπŸ‡ΈUnited States debra-v

    Updated patch from #6. Works with core 10.2.6.

Production build 0.69.0 2024