geofield should compute values not only in form validation but in hook_field_presave.
see maybe related discussion at #1265036: Feeds + Addressfield Integration

the attached patch does so.
note the ugly widget type to master_column conversion
it doesn't remove geofield_compute_values from the validation hook yet, maybe it should?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dasjo’s picture

without dpm :)

batje’s picture

I used this patch in combination with this Feeds integration patch. It works, as long as the widget type is (tested) latlon, or logically, but untested wkt & bound (not sure what the geolocation field is)

the else statement:

+        else {
+          $master_column = 'wkt';
+        }

wont work for the 'All Textfields' (internally 'textfields') type. If you do not provide a WKT value, it will wipe all values.

There is 2 options to fix this:

- don't calculate anything, just store as deliverd (in theory, you are providing all textfields, so there is nothing to calculate). Disadvantage is that the node may be stored in an inconsistent state
- do some funky internal prioritarisation, where you recalculate first based on wkt (if available) then on latlon (if available) then on bounds (if available)

Funky is not simple, so i go for option 1.

Brandonian’s picture

Thanks for the patch, dasjo! Works as advertised, committed.

I'm not a fan of how data is potentially computed twice with this patch, but I'm willing to incur a little developer debt to get #1242206: Feeds Integration committed a timely manner. I would really like to see a patch that handles that. Once the module goes beta, I might try to refactor a bit to handle this if no one else submits a patch first.

Brandonian’s picture

Status: Needs review » Fixed

Marking as fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.