When a validation error occurs in a form, Geofield will not redisplay the map. An empty div is displayed.

To reproduce:
1. create a nodetype/form with a required field AND a Geofield (not required).
2. open de node/add/thenodetype
3. Submit the form without filling in anything
The form will be redisplayed, with a validation error "Title field is required". The area where the map should be is empty.

Comments

John_NL’s picture

Status: Active » Needs review
StatusFileSize
new2.66 KB

This problem can be fairly easily solved. The reason for failing is that the hook-function geofield_field_widget_form is not called after validation errors. As the rendering of openlayers maps depend on a couple of javascripts that are loaded through this function we need to call the necessary functions from #build_after (which calls a function on every render).

As I don't have good testing facilities (nor time), code is presented as "works for me".

Changes in the attached file are marked "20111005JZ"

HTH
John

phayes’s picture

Status: Needs review » Closed (cannot reproduce)

I think this has been fixed - at least I can' reproduce it. We've pretty seriously refactored the widget - so its not surprising. If you can reproduce this using the latest versions, please re-open.

bruvers’s picture

Version: 7.x-1.0-alpha5 » 7.x-1.0
Status: Closed (cannot reproduce) » Active
StatusFileSize
new45.42 KB

I'm using version 7.x-1.0. If an form validation error occurs the map isn't displayed. No JS or CSS files related to Geofield or OpenLayers are loaded after form validation. The only way for a user to get around this is to start filling out the form from scratch and hope to get it all right this time.

Brandonian’s picture

Status: Active » Fixed

I've made some commits based on @John_NL's code to address this issue.

- 7.x-1.x: http://drupalcode.org/project/geofield.git/commit/1978a0f
- 7.x-2.x: http://drupalcode.org/project/geofield.git/commit/351262c

Status: Fixed » Closed (fixed)

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