Symfony中的无效验证程序 - sfForkedApplyPlugin

时间:2011-09-22 22:05:33

标签: php symfony1

    public function configure()
        {
            parent::configure();

            $email = $this->getWidget('email');
            $class = get_class($email);
            $this->setWidget('email2', 
                    new $class( array(), array('maxlength' =>
     

$ email-> getAttribute('maxlength'))                   ));                   $ this-> widgetSchema-> moveField('email2',   sfWidgetFormSchema :: AFTER,'email');

     

$这 - > widgetSchema-> setNameFormat( 'sfApplyApply [%s]的');                   $这 - > widgetSchema-> setFormFormatterName( '列表');

            $this->setValidator('email', new sfValidatorAnd(
     

阵列(                       新的sfValidatorEmail(array('required'=> true,   'trim'=>是)),                       new sfValidatorString(array('required'=> true,   'max_length'=> 80)),                       新的sfValidatorDoctrineUnique(                               array('model'=>'sfGuardUserProfile',   'column'=> '电子邮件'),                               array('invalid'=>'一个帐户   电子邮件地址已存在。如果您忘记了密码,   单击“取消”,然后“重置我的密码。”'))                   )));

            $this->setValidator('email2', new sfValidatorEmail( 
                    array( 'required' => true, 'trim' => true )));

            $schema = $this->validatorSchema;

            // Hey Fabien, adding more postvalidators is kinda
     

详细!                   $ postValidator = $ schema-> getPostValidator();

            $postValidators = array( 
                new sfValidatorSchemaCompare( 'password',
     

sfValidatorSchemaCompare :: EQUAL,                               'password2',array(),array('invalid'=>   '密码不匹配。')),                       新的sfValidatorSchemaCompare('email',   sfValidatorSchemaCompare :: EQUAL,                               'email2',array(),array('invalid'=>'The   电子邮件地址不匹配。')));

            if( $postValidator )
            {
                $postValidators[] = $postValidator;
            }

            $this->validatorSchema->setPostValidator( new
     

sfValidatorAnd($ postValidators));               }       }

为什么如果在数据库中另一个用户使用相同的电子邮件,那么我有两个错误 - 首先是这个信息,第二个 - 电子邮件不匹配。

我该如何解决?

0 个答案:

没有答案