问题描述
||
我已经在位于
{app}/lib/form/doctrine/base
的\'BaseUserForm \'类中编写了此代码,试图在EMAIL字段中添加两个验证器。
$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教程没有太大帮助。
请分享一些好的博客/文章/论坛,在这些博客/文章/论坛中我可以找到与上述问题有关的帮助。
谢谢
解决方法
sfValidatorAnd()
会有所帮助;
祝好运
, \'email\' => new sfValidatorEmail(array(\'max_length\' => 25,\'required\' => TRUE),array(\'invalid\' => \'The email address is invalid.\',\'required\' => \'Email Id is required.\',\'max_length\'=> \'Maximum 25 characters allowed.\')),