When generating tokens for an addressfield that has the country hidden set as an option, the only data provided is the mode:

Line 140 in addressfield.tokens.inc:

 $form = addressfield_generate($address, $data['format_handlers'], array('mode' => 'form'));

However, the module wants more information:

function addressfield_format_address_hide_country(&$format, $address, $context = array()) {
  // Hide the country element only if the whole field is required, otherwise
  // there will always be an additional None option.
  if ($context['mode'] == 'form' && $context['instance']['required']) {

So if instance isn't provided, it throws a notice.

CommentFileSizeAuthor
#3 undefined_index-2587621-3.patch807 bytesnvahalik
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nvahalik created an issue. See original summary.

nvahalik’s picture

Issue summary: View changes
nvahalik’s picture

Status: Active » Needs review
FileSize
807 bytes
skwashd’s picture

Status: Needs review » Reviewed & tested by the community
Related issues: +#2391989: Notice: Undefined index: instance

I am running 7.x-1.2 which includes #2391989: Notice: Undefined index: instance. I am seeing this error.

Applying @nvahalik's patch from #3 fixes it. The code looks good to me. RTBC

bojanz’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks.

  • bojanz committed 24e41cd on 7.x-1.x authored by nvahalik
    Issue #2587621 by nvahalik: Undefined index: instance in...

Status: Fixed » Closed (fixed)

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