We're getting this error lately, on a webform using the address field:

Warning: Missing argument 2 for addressfield_default_values(), called in /home/mysite/public_html/sites/all/modules/addressfield_tokens/addressfield_tokens.components.inc on line 120 and defined in addressfield_default_values() (regel 375 van /home/mysite/public_html/sites/all/modules/addressfield/addressfield.module).
    Notice: Undefined variable: instance in addressfield_default_values() (regel 376 van /home/mysite/public_html/sites/all/modules/addressfield/addressfield.module).
    Notice: Undefined index: bundles in _addressfield_country_options_list() (regel 874 van /home/mysite/public_html/sites/all/modules/addressfield/addressfield.module).
    Warning: Invalid argument supplied for foreach() in _addressfield_country_options_list() (regel 874 van /home/mysite/public_html/sites/all/modules/addressfield/addressfield.module).
    Notice: Undefined variable: instance in addressfield_default_values() (regel 377 van /home/mysite/public_html/sites/all/modules/addressfield/addressfield.module).
    Notice: Undefined variable: instance in addressfield_default_values() (regel 404 van /home/mysite/public_html/sites/all/modules/addressfield/addressfield.module).
    Warning: Missing argument 2 for addressfield_default_values(), called in /home/mysite/public_html/sites/all/modules/addressfield_tokens/addressfield_tokens.components.inc on line 120 and defined in addressfield_default_values() (regel 375 van /home/mysite/public_html/sites/all/modules/addressfield/addressfield.module).
    Notice: Undefined variable: instance in addressfield_default_values() (regel 376 van /home/mysite/public_html/sites/all/modules/addressfield/addressfield.module).
    Notice: Undefined index: bundles in _addressfield_country_options_list() (regel 874 van /home/mysite/public_html/sites/all/modules/addressfield/addressfield.module).
    Warning: Invalid argument supplied for foreach() in _addressfield_country_options_list() (regel 874 van /home/mysite/public_html/sites/all/modules/addressfield/addressfield.module).
    Notice: Undefined variable: instance in addressfield_default_values() (regel 377 van /home/mysite/public_html/sites/all/modules/addressfield/addressfield.module).
    Notice: Undefined variable: instance in addressfield_default_values() (regel 404 van /home/mysite/public_html/sites/all/modules/addressfield/addressfield.module).

As you can see the errors are related to the Addressfield Tokens module as the Address field module, so I'm not sure which one is causing the issue (feel free to move it if deemed appriopriate).

I wish I had more information on this in order ro reproduce it, but unfortuantely we have no idea why it suddenly popped up there (someone reported this to us).

The address fields are gone too, except for the select list to pick a country.

It happens to the currently recommended version as well as to the dev version.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

knalstaaf’s picture

Project: Address Field » Addressfield Tokens
Version: 7.x-1.x-dev » 7.x-1.5

Disabling the Addressfield Tokens module drastically removes these errors (fields remain missing though), only this one persists, after disabling the Addressfield module as well:

Notice: Undefined index: addressfield in webform_component_include() (regel 4414 van /home/mysite/public_html/sites/all/modules/webform/webform.module).

Because the address fields weren't cleaned up after disabling the module. (Cleaning them up manually and clearing the cache fixes this.)

knalstaaf’s picture

Don't want to get every possible party involved, but tokens in the e-mail template are using fields of the Webform layout module.

These tokens look like this: [submission:values:webformlayoutfield_machinename:fieldinlayoutbox_machinename]

This is how the tokens work with WFL, in order to get them printed in the e-mail. So it's not unthinkable that there's a struggle there.

richH’s picture

MEGA PROBLEM!!
Just updated addressfield to latest version and now have these errors. Real big mucho problemo here...!
Rch

joel_osc’s picture

I think this is a result of addressfield changing its default_values function to bring in $field and $instance - which I don't think we really have since this is a webform component. I have created a patch that just adds a local default_values function and also a new form element to allow the user to select a default country.

joel_osc’s picture

Category: Support request » Bug report
Status: Active » Needs review
owenpm3’s picture

#4 fixed the errors and I was able to select the default value for the country. That default was then carried into the webform correctly.

Based on what I've seen in other posts, you'll have to go back and fix any webform that had a previously declared default country as your data was lost with the latest upgrade of the addressfield module.

wylbur’s picture

Status: Needs review » Reviewed & tested by the community

Applied the patch to a fresh install of Drupal 7.34 with addressfield and addressfield token module.

The patch in #4 resolved the errors. Marking as RTBC.

scotwith1t’s picture

+1 The new addressfield module definitely breaks the webform integration and this patch works quite nicely. Thanks!

Eli-T’s picture

Tested patch with #4 with Drupal 7.36, works fine.

Poieo’s picture

This does resolve the error and provide a default value which is nice. But, it seems to force a default value. I'm not sure this is ideal in every situation?

Amad Tababa’s picture

Applied and Tested patch with #4 with Drupal 7.36, works fine.

joel_osc’s picture

@Poieo is correct, I will need to add the ability to not have a default country.

joel_osc’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
2.74 KB

Here is the same patch except that it also allows the default country not to be set. Please review, thanks!

fonant’s picture

Patch from #13 works nicely here, so I can set the default country per-field.

Sinan Erdem’s picture

Patch from #13 works for me. Thanks for that.

victoriachan’s picture

Patch from #13 works for me too. Thanks very much.

  • markie committed ac10e55 on 7.x-1.x authored by joel_osc
    Issue #2434707 by joel_osc: Warning: Missing argument 2 for...
markie’s picture

Status: Needs review » Fixed

Applied patch #13 and created dev branch / release. Once dev release is available, please open new issues against that.

Status: Fixed » Closed (fixed)

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

rparve@symphony3.com’s picture

Patch from #13 works for me too. Thanks very much.

aprilr’s picture

#13 Patch worked great! Thanks!

dasginganinja’s picture

I see that the patch is now in dev. Is there any sort of roadmap for when the next release of addressfield_tokens will be available?

deanflory’s picture

Is that dev version going to be revealed on the project page? It currently does not show.

mccrodp’s picture

You can get it from the git repo. The branch naming is wrong here if a dev release was intended for the project page. It would need to be a commit on the main 7.x branch.

https://www.drupal.org/node/1559772/git-instructions/7.x-1.x-dev/nonmain...

wOOge’s picture

Patch #13 works as applied to 7.x-1.5 Dated: 2014-Oct-29

bogdan.negru’s picture

Why is this issue marked as fixed if the fix is not included in the latest stable version?

martin.davidson’s picture

Same question as above - the patch works, can it get merged in?