如何在symfony 1.4中的字段上添加多个验证符

问题描述

|| 我已经在位于
{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.\')),
    

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...