I'm not sure if this is a bug in the Addressfield module or Addressfield autocomplete, but I suspect the latter and hence post it here.

Steps to reproduce:

  1. Add an addressfield to a content type so that the widget of the addressfield is "Addressfield Autocomplete" (which is the default when Addressfield Autocomplete module is enabled.
  2. Try to create new content. Verify that the addressfield autocomplete is working as expected.
  3. Change the widget to "Dynamic Address From".
  4. Now try to create new content. You'll get a PHP notice: Notice: Undefined offset: 0 in addressfield_field_widget_form() (line 509 of /path/to/drupal/www/sites/all/modules/addressfield/addressfield.module).
  5. Changing the widget type back and forth does not take the notice away.

Comments

  • adammitchell committed 7c1ae94 on 7.x-1.x
    Issue #2294895 by masipila : Fix to stop array index offeset error when...
adammitchell’s picture

Status: Active » Needs review

Hi Markus,

It appears that it is an issue with both modules. When you switch between widgets, the instance config gets overriden with an empty array for the default value.

I have written a patch for this in the addressfield autocomplete so it works when switching from dynamic address widget to addressfield autocomplete; however if you are switching back again the issue remains, as you are still trying to access that offset. You can remove the error by editing the field and just resaving it without making any updates.

Adam

masipila’s picture

Status: Needs review » Reviewed & tested by the community

Re-tested successfully with the latest DEV version.

adammitchell’s picture

This commit d87797a on 7.x-1.x, adds a fix in for this notice which will fixed it when switching to and from both types of widgets.

adammitchell’s picture

Status: Reviewed & tested by the community » Closed (fixed)