It appears as though when you use addressfield in a multi value scenario, only the first value/address stored in the field is accessible via tokens. This patch makes all the addresses accessible via tokens.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lionguard created an issue. See original summary.

lionguard’s picture

Patch provided by Drupal.org user @italdenko

lionguard’s picture

FileSize
5.91 KB

Looks like something went wrong with that last patch, here is another attempt -

kenorb’s picture

Status: Active » Needs review
lionguard’s picture

FileSize
12.03 KB

Attached is a new patch created with GIT rather than the patch comand.

lionguard’s picture

FileSize
7.47 KB
Christophe Bourgois’s picture

#6 is working for me, many thanks !!!

alzz’s picture

#6 working for me too, used with pathauto, working like a charm.

monstrfolk’s picture

#6 does now work.

git apply -v addressfield_3.patch
Checking patch addressfield.tokens.inc...
error: while searching for:
          $format_handlers = $instance['widget']['settings']['format_handlers'];
        }

        // Generate the necessary address field tokens for the entity.
        $replacements += token_generate('address-field', $addressfield_tokens, array('address-field' => $data['entity']->$field_name, 'format_handlers' => $format_handlers), $options);
      }
    }
  }

error: patch failed: addressfield.tokens.inc:223
error: addressfield.tokens.inc: patch does not apply
Falco010’s picture

FileSize
7.09 KB
14.21 KB

Also got the following when trying to apply this patch to 1.x-dev or 1.2 release:

Checking patch drupal/sites/all/modules/contrib/addressfield/addressfield.tokens.inc...
error: while searching for:
function addressfield_token_info_alter(&$data) {
  // Loop over every address field on the site.
  foreach (array_filter(field_info_field_map(), 'addressfield_field_map_filter') as $field_name => $field) {
    foreach ($data['tokens'] as $group => $token){
      if (isset($data['tokens'][$group][$field_name]) && is_array($data['tokens'][$group][$field_name])) {
        // Set the token type for the field to use the addressfield child tokens.
        $data['tokens'][$group][$field_name]['type'] = 'address-field';

error: patch failed: drupal/sites/all/modules/contrib/addressfield/addressfield.tokens.inc:90
error: drupal/sites/all/modules/contrib/addressfield/addressfield.tokens.inc: patch does not apply

Recreated patch #6 so it applies to the latest release/dev

Falco010’s picture

Falco010’s picture

FileSize
7.09 KB

Patch path was not correct, fixed that