I am getting this error :
i have entity reference field in my node create form and using entity connect module to create a new entity from the node create form the new node form opens in the same page , we will be redirected to the original node create form when we return to node after creating the referenced entity we get this error
we also have the geofield in the same form
Notice: Undefined index: default_value in geofield_field_presave() (line 280 of C:\wamp\www\xxxxxx\sites\all\modules\geofield\geofield.module).
Warning: Invalid argument supplied for foreach() in geofield_field_presave() (line 290 of C:\wamp\www\xxxxx\sites\all\modules\geofield\geofield.module).

Comments

boabjohn’s picture

We do not use the entity connect module and just started getting the same error today.
Our site is basic D7, everything up to date or in dev if required. Geofield is storing wkt spatial data after geocoding a addressfield.
We did not have this issue 4 days ago: now a non-U1 user is getting it.
Wondering about field permissions and that sort of thing given the circumstances.

@kaizerking: any clues? How did you go sorting it out, or are you still looking for some more assistance?

kaizerking’s picture

@boabjohn ,No solution so far

boabjohn’s picture

I can confirm that this error is still ocurring even though we have shifted platforms (Ubuntu to Debian).
In a node type with a address_field which feeds the geofield, on node creation the error is returned:

Warning: Invalid argument supplied for foreach() in geofield_field_presave() (line 290 of /home/mysite/htdocs/drupal/sites/all/modules/geofield/geofield.module).

So this is on line 290 (not 280), and is related to an invalid argument (not undefined index). But it seems to be happening in a similar stage of processing.

This only happens on node create: it does not appear on node edit or delete.

Any thoughts out there?

greenskunk’s picture

Have you tried the latest geoPHP library? See http://drupal.org/node/1881056

Good luck

mikhailian’s picture

Hello,

I can confirm getting

Notice: Undefined index: default_value in geofield_field_presave() (line 280 of /var/www/test/sites/all/modules/contrib/geofield/geofield.module).
Warning: Invalid argument supplied for foreach() in geofield_field_presave() (line 290 of /var/www/test/sites/all/modules/contrib/geofield/geofield.module).

with geofield-7.x-2.0-alpha2+6-dev and geophp-7.x-1.1.

retiredpro’s picture

I am also getting this message. using geofield 7.x-2.x-dev (2013-Jan-13), geophp 7.x-1.7, and geophp library 1.1 from the link above

Warning: Invalid argument supplied for foreach() in geofield_field_presave() (line 290 of /var/www/testsite.com/htdocs/sites/all/modules/geofield/geofield.module).

greenskunk’s picture

Be sure to apply @phayes patch, from 2013-01-25, at http://drupal.org/node/1862922#comment-6980730

retiredpro’s picture

Patch didnt fix it for me.

Ovation1357’s picture

I hit this exact same issue when using this field in a user profile. Having looked into it I'm fairly sure I understand why I'm seeing it:

1) When 'Widget Type' is set to 'Geocode from another field', there is no option to set a default value for the field.
2) I had made the field optional.

277     if ($instance['required'] == 0 && empty($items)) {
278       $entity_ids = entity_extract_ids($entity_type, $entity);
279       if (empty($entity_ids[0])) {
280         $items = $instance['default_value'];
281       }
282     }

We can see above that if the field is not marked as required and $items is empty it tries to set $items using the Default Value. But there is no default value!!

For me, making the field Required bypasses this problem .
When using 'Geocode from another field', setting required does not actually show the GeoField field on the creation form and it's automatically handled in the background.

Hope this helps someone.

JSCSJSCS’s picture

Thanks Ovation1357. Setting the geofield to required fixed it for me too. This should probably be fixed to not require that though.

kingfisher64’s picture

I had two instances of this error both fixed with #9 suggestion by Ovation1357 - thanks.

Notice: Undefined index: default_value in geofield_field_presave() (line 280 of sites/all/modules/geofield/geofield.module). 

Warning: Invalid argument supplied for foreach() in geofield_field_presave() (line 290 of sites/all/modules/geofield/geofield.module). 
gamesfrager’s picture

+1 setting the filed to required fixed it for me as well.

kingfisher64’s picture

Since having to set the field to required isn't really a proper fix, but does work, how would this best be handled?

deanflory’s picture

I too am having the same errors occur. Just posting here to keep the issue current as all of my modules are up-to-date, applying the patch mentioned in #7 along with updating the geoPHP library, will see if I have the same problems afterwards.

mac_weber’s picture

There is a duplicate issue #1886852: Geofield: Empty values on widgets with default values skip validation
Which one shall we close? This problem started after the other issue.

gamesfrager’s picture

I vote for closing the other one as the title of this issue is the exact error that people get, and most likely is what people will be using in their search.

jpstrikesback’s picture

#1886852: Geofield: Empty values on widgets with default values skip validation contains a fix so I wouldn't close it :) see my comment in #9

Brandonian’s picture

Status: Active » Closed (duplicate)
leoklein’s picture

#9 worked for me. Thanks!

zilla’s picture

#9 works still (october) with latest geofield