【发布时间】:2011-06-15 06:54:30
【问题描述】:
我已在位于 {app}/lib/form/doctrine/base
我正在尝试将两个验证器添加到 EMAIL 字段的“BaseUserForm”类中编写此代码。
$this->setValidators(array(
'id' => new sfValidatorChoice(array(
'choices' => array(
$this->getObject()->get('id')
),
'empty_value' => $this->getObject()->get('id'),
'required' => false
)),
'name' => new sfValidatorString(array('max_length' => 50)),
'email' => array(
new sfValidatorString(array('max_length' => 100)),
new sfValidatorEmail(array('trim' => true))
),
'password' => new sfValidatorString(array('max_length' => 100)),
'retyepassword' => new sfValidatorString(array('max_length' => 100)),
'city_id' => new sfValidatorDoctrineChoice(array(
'model' => $this->getRelatedModelName('Cities')
)),
'phone' => new sfValidatorNumber(),
'created' => new sfValidatorDateTime(),
'updated' => new sfValidatorDateTime(),
));
上面的代码在为电子邮件字段定义两个验证器时出错。
此外,我发现很难找到这些验证器的相关代码(示例显示用法)。 jobeet 教程没有太大帮助。
请分享一些不错的博客/文章/论坛,我可以在其中找到与上述问题相关的帮助。
谢谢
【问题讨论】:
标签: forms symfony-1.4 field validation