2011-12-28 13:56
采纳率: 0%
浏览 22


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:

'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?

图片转代码服务由CSDN问答提供 功能建议


问题是我在客户端验证中使用了ajaxed表单,该表单使用Drupal.settings来获取一些数据。 作为验证年龄的示例,我将以下数据设置为drupal设置:

   'year'=> date('Y'),
   'month'=> date('m'),
   'day'=> date('d')
 )), '设置');


但是,每当用ajax重新加载表单时,它都会将上述设置合并到Drupal.settings中,并且如果在第一次调用 Drupal.settings.viewpoint_profile.year == 2011 时,在ajax重新加载后,它就是 Drupal .settings.viewpoint_profile.year == array(2011,2011),所以我再也无法在js中将其用作字符串了。

因此,基本上,在添加它们之前清除viewpoint_profile的设置会很好,但是我没有设法找到方法? 还是可能有另一种方法来解决这个问题?     

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • csdnceshi64
    游.程 2014-12-08 20:34

    If you must use the drupal settings than why not as those values to an 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.

    点赞 评论