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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

GaborTorok’s picture

Title: Respect #parents for geocoder_field » Geocode from another field doesn't handle nested form structures

Additionally 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.

GaborTorok’s picture

Status: Active » Needs review
FileSize
2.34 KB

This 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.

GaborTorok’s picture

Issue summary: View changes

Made the description more accurate

ryan.gibson’s picture

Version: 7.x-2.x-dev » 7.x-2.3
Issue summary: View changes

Rerolling this patch against the latest stable version of geofield.

ryan.gibson’s picture

Adding the patch :)

solotandem’s picture

@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:

$field_value[$langcode] = $field_value[LANGUAGE_NONE];

Is there some reason you suggest these extra statements?

Otherwise, the patch is RTBC.

solotandem’s picture

Assigned: GaborTorok » Unassigned
FileSize
2.49 KB

Attached patch removes the extraneous statements from previous patch.

jasonawant’s picture

Hi,

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.

// Set the values - geofields do not support languages
return array(LANGUAGE_NONE => $values);

New patch attached. Jason