I am programmatically creating nodes with a Field Collection that contain a geocoded field, the field where i take the data from for the geocoding is a computed field (i have already applied this patch: https://www.drupal.org/node/1679926 ). The problem is that the map from the field appears only after i open the node and save it from the interface, the nodes i have created through node_save() in my code won't show the map until i save them again from drupal interface. I have tried the geocoder patch in the first comment of this discussion How to programmatically iterate over nodes, load into form, and save the form? but it didn't work (the geofield patch doesn't work because it's for 7.x-1.x version), i have also tried saving them all with bulk operations but it doesn't work

Is there any way to solve this? I was thinking about saving nodes as it was done through form submission in my code but i don't know if it's possible, also i don't want to go as far as having to use selenium or something similar to do a bulk form submission


Geofield runs geofield_field_presave() before saving the data, and calculates various values for the field. Use the devel tab, and check whether the 'geom' array of the geofield is populated and the others are empty. That was my case, and I am using geofield_compute_values() to calculate these data, but afterwards I repopulate the 'geom' array again, because I think it converts it into WKB. You can take a look at my code. There might be other, better solutions too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.