Steps to reproduce:
- Instal Drupal 7.21 with Ctools 7.x-1.2, Entity 7.x-1.0, Addressfield 7.x-1.0-beta3, Profile2 7.x-1.3, GeoPHP 7.x-1.7, Geocoder 7.x-1.2, Openlayers 7.x-2.0-beta3 and Geofield 7.x-2.x-dev;
- Add adressfield called Address to provided Profile2 profile (Main Profile);
- Add geofield called Location to provided Profile2 profile (Main Profile) and choose wiget type OpenLayers Map;
- Configure Location field with following values:
- Store each simple feature as a separate field;
- Allow only Point in Available Features;
- Enable geocoding of location data;
- Geocode from created addressfield;
- Google Geocoder with default options;
- Go to user Profile2 page, fill Address field and save;
- Go to the same user Profile2 page and click button "Find using Adress field".
What should happen:
Map has a new marker in the geographical coordinates corresponding to the address we used.
What happens:
Nothing and watchdog throws error:
Notice: Undefined index: field_address in openlayers_use_geocoder_submit() (line 329 of /Users/guilherme/Sites/drupal/sites/all/modules/geofield/geofield.widgets.openlayers.inc).
followed by:
User error: geocoder_widget_get_field_value: You must pass either $source_field_values OR $entity in geocoder_widget_get_field_value() (line 183 of /Users/guilherme/Sites/drupal/sites/all/modules/geocoder/geocoder.widget.inc).
Aditional Notes:
Repeating steps 3 to 6 on a regular content type works as expected.
Tested on a Macbook Pro with Mac OSX 10.8.2, Apache 2.2.22, PHP 5.4.11 and Maria 5.5.29 after first noticing this issue on a VPS with Debian Squeeze 6.07, Apache 2.2.16, PHP 5.3.3 and MySQL 5.1.66
Odd behavior with Profile2 and Geofield was first noticed after trying to get Leaflet Widget and Geofield Gmap to work with Geofied 7.x-1.1 for fields in Profile2 pages and not succeeding.
Comments
Comment #1
sano commentedPossibly related to this issue: http://drupal.org/node/1963242
Comment #2
finn lewisI have the same behaviour, with the same watchdog message.
I read through https://drupal.org/node/1963242 and tried the latest Geofield 7.x-2.x-dev but still get the same behaviour on profile2 entities.
Comment #3
eugenesia commentedIt seems the structure of a user profile edit form is different from that of a node edit form. The widget's submit handler works for a node edit form but fails when it's a user profile editing form for a profile2 profile. The buggy function is openlayers_use_geocoder_submit() in the file geofield.widgets.openlayers.inc.
My solution was to replace the buggy submit handler using a hook. I'm sharing my workaround in case others find it useful. I implemented the hook in a module named mymodule.
The function below is our amended widget submit function handler. In the 'modified' section, I've changed $form_state['values'][$geocoder_field][$langcode] to $form_state['input'][$parents[0]][$geocoder_field][$langcode]. It seems to work for this case, but I haven't tested it thoroughly. I'd appreciate any inputs you have.
Comment #4
davidpugh commentedI had this same problem. I fixed it by uninstalling geofields 7.x-2.1
and installing geofields 7.x-2.0.
My geofield was not autofilling with "Geocode from another field" on my new Profile2 field.
I changed geofields 7.x-2.1 to 7.x-2.0 and now my "geocode from another field" field on my new Profile2 profile
is getting populated automatically with my geo location data.
There is something wrong with the new geofields 7.x-2.1 version.