js settings in multistep form

gianlubus - March 18, 2009 - 18:11
Project:Google Maps Tools
Version:5.x-1.3
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

I'm trying to create a multistep form (wizard) with two gmap fields, following this technique http://drupal.org/node/162373.
This works very well and allow me to divide a long form with two 'big' gaddress widgets in 2 steps.
It is based on hook_form_alter() and unset the fields not required in each step.
When the gmap field is called the first time, everything works fine (map, search button,etc), but in the next step, the second gmap field doesn't work (no map, etc).
After a long comparison between the html pages generated with/without multistep forms I discovered the problem is in the double call to the drupal_add_js for the settings.
If the form is called once, the js settings are written once also if there are more then one gmap field; indeed, when I call and recall the form creation the settings are added and this break the field javascripts.
Someone knows how to avoid the double insert of the js settings?

 
 

Drupal is a registered trademark of Dries Buytaert.