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.
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?
Comment | File | Size | Author |
---|---|---|---|
#1 | geofield_field_presave.patch | 1.09 KB | dasjo |
geofield_field_presave.patch | 1.11 KB | dasjo | |
Comments
Comment #1
dasjowithout dpm :)
Comment #2
batje CreditAttribution: batje commentedI 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:
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.
Comment #3
Brandonian CreditAttribution: Brandonian commentedThanks 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.
Comment #4
Brandonian CreditAttribution: Brandonian commentedMarking as fixed.