I'm getting this error when changing Country in user edit page:

Notice: Undefined index: province in _location_country_ajax_callback() (line 1098 of /misc/40/000/122/664/4/user/web/name.com/sites/all/modules/location/location.module).

Comments

olmyr’s picture

simple fix for me

function _location_country_ajax_callback($form, $form_state) {
  if (arg(2) == 'locations') {
    return $form['locations'][arg(3)]['province'];
  }
  else {
    if(!empty($form[arg(2)][arg(3)][arg(4)]['province'])) {
        return $form[arg(2)][arg(3)][arg(4)]['province'];
    }
    else {
        return '';
    }
  }
}
tuwebo’s picture

Same issue here.
Notice that my settings are as follows:
------------------------------------------------------------
Location name: Allow
Street Location: Do not collect
Additional: Do not collect
City: Do not collect
State/Province: Do not collect | Autocomplete
Postal Code: Do not collect
Country: Allow
Coordinate Chooser: Allow
------------------------------------------------------------

Changing State/Province:
From:
Do not collect | Autocomplete

To:
Do not collect | Dropdown

Will solve the error message (wich is the expected behavior since dropdown doesn't need ajax, isn't it?), but doesn't solve the issue. This is just a work around.

euginewm’s picture

I also got this problem. Your solution helped me

ankur’s picture

Status: Active » Closed (fixed)

Fixed in 7.x-3.x. Thanks for the report.

tamerzg’s picture

Status: Closed (fixed) » Active

No this is not fixed, or maybe it got broken again!
Additionally its not saving any data for me.

matulis’s picture

Notice still there. Here is patch, thanks to mirgorod_a #1

antonyanimator’s picture

Received this error also after saving a location field

Notice: Undefined index: province in _location_country_ajax_callback() (line 1149 of /home/e-smith/files/ibays/sota4/html/sites/all/modules/location/location.module).

mxr576’s picture

Issue summary: View changes

Me too.

yce’s picture

It looks like, if you set the State/Province field to 'Do not collect' and widget to 'autocomplete', then after Country selection it throws the mentioned error. Try to set the widget to 'dropdown', it fixed for me.

jippie1948’s picture

The #9 suggestion did not work for me.

tucho’s picture

The patch from #1346932-6: Notice: Undefined index: province in _location_country_ajax_callback() doesn't apply anymore.

I attach the patch for the current dev. It applies to the 7.x-3.3 version too.

fliwatuet’s picture

Setting the widget to 'dropdown' is not working for me. The above patch ist also not working for me, I am always getting this notice.

DrCord’s picture

The patch in #11 kinda applies to the latest dev, but only part of the patch, as part of it is already implemented...only

else {
  return '';
}

from the end of the patch is needed.

DrCord’s picture

after another update to the module, the change that actually works in the latest dev version (7.x-5.x-dev) to patch this is:

change

elseif (isset($form[arg(2)][arg(3)][arg(4)])) {

to

elseif ( isset($form[arg(2)][arg(3)][arg(4)]) && isset($form[arg(2)][arg(3)][arg(4)]['province']) ) {
zeezhao’s picture

Fyi - still an issue in 7.x-3.x-dev

jay.lee.bio’s picture

It looks like this is mostly a duplicate of https://www.drupal.org/node/1997658. A recent patch provided there (#24) might work, which I haven't tried yet.

jay.lee.bio’s picture

Status: Active » Closed (duplicate)

I just tried the patch and it does work, so I'm closing this issue as duplicate.

rudiedirkx’s picture