invalid validators in Symfony
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' );
$this->widgetSchema->setNameFormat('sfApplyApply[%s]'); $this->widgetSchema->setFormFormatterName('list');
$this->setValidator('email', new sfValidatorAnd(
array( new sfValidatorEmail( array('required' => true, 'trim' => true) ), new sfValidatorString( array('required' => true, 'max_length' => 80) ), new sfValidatorDoctrineUnique( array( 'model' => 'sfGuardUserProfile', 'column' => 'email'), array('invalid' => 'An account with that email address already exists. If you have forgotten your password, click "cancel", then "Reset My Password."') ) )));
$this->setValidator('email2', new sfValidatorEmail(
array( 'required' => true, 'trim' => true )));
$schema = $this->validatorSchema;
// Hey Fabien, adding more postvalidators is kinda
verbose! $postValidator = $schema->getPostValidator();
$postValidators = array(
new sfValidatorSchemaCompare( 'password',
sfValidatorSchemaCompare::EQUAL, 'password2', array(), array('invalid' => 'The passwords did not match.') ), new sfValidatorSchemaCompare( 'email', sfValidatorSchemaCompare::EQUAL, 'email2', array(), array('invalid' => 'The email addresses did not match.') ) );
if( $postValidator )
{
$postValidators[] = $postValidator;
}
$this->validatorSchema->setPostValidator( new
sfValidatorAnd($postValidators) ); } }
why if is in database another user with same email then i have two error - first with this information, and second - The emails did not match.
how can i fix it?
链接地址: http://www.djcxy.com/p/69748.html上一篇: 如何在PHP中修改特殊字符\ r
下一篇: Symfony中的验证器无效