Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If the field widgets are deeper in the form structure and not at the root of the form, the geocoding fails, manily because it assumes that the geocoder_field is at the root of the form, but I think should only assume that the geocoder_field is in the same container as the geofield widget.
Comments
Comment #1
GaborTorok CreditAttribution: GaborTorok commentedAdditionally openlayers_widget_geocode() uses #parents instead of #array_parents for retrieving elements from the form structure, but #parents defines the path in form_state['values'] and #array_parents defines the path in the form structure.
Comment #2
GaborTorok CreditAttribution: GaborTorok commentedThis patch solves the problems I described and now the geocoding works with my form that has the geofield deep in the form structure with #parents != #array_parents.
Comment #2.0
GaborTorok CreditAttribution: GaborTorok commentedMade the description more accurate
Comment #3
ryan.gibson CreditAttribution: ryan.gibson commentedRerolling this patch against the latest stable version of geofield.
Comment #4
ryan.gibson CreditAttribution: ryan.gibson commentedAdding the patch :)
Comment #5
solotandem CreditAttribution: solotandem commented@ryanissamson, I came up with essentially the same patch (before finding this issue..lol), but did not include the statements that set
$field_value[LANGUAGE_NONE]
instead of$field_value[$langcode]
only to be followed up with this:Is there some reason you suggest these extra statements?
Otherwise, the patch is RTBC.
Comment #6
solotandem CreditAttribution: solotandem commentedAttached patch removes the extraneous statements from previous patch.
Comment #7
jasonawantHi,
The additional step sets the field value using the form elements language key, in case the field has been translated. I've removed this line
$field_value[$langcode] = $field_value[LANGUAGE_NONE];
, which unsets the returned value when using this on the node add form. At this point, the form element language is undefined.Despite lines 305 and 306 in geocoder.widget.inc, the field can be translated.
New patch attached. Jason