The problem is that I am using ajaxed form with clientside validation which uses Drupal.settings to get some data. As an example to validate age I set following data to drupal settings:
drupal_add_js(array(
'viewpoint_profile' => array(
'year' => date('Y'),
'month' => date('m'),
'day' => date('d')
)), 'setting');
But whenever form is reloaded with ajax it merges above settings to Drupal.settings and if on first call Drupal.settings.viewpoint_profile.year == 2011
, after ajax reload it is Drupal.settings.viewpoint_profile.year == array(2011, 2011)
, so I can't use this in js as a string any more.
So basically it would be nice to clear settings for viewpoint_profile before adding them, but I didn't manage to find how? or may be there is another way to solve this problem?
If you must use the drupal settings than why not as those values to an array.
drupal_add_js(array(
'viewpoint_profile' => array(array(
'year' => date('Y'),
'month' => date('m'),
'day' => date('d')
))), 'setting');
You can also add a key that will be passed with the form.