Symfony2表示重复错误也会触发空白错误

时间:2011-10-06 15:46:53

标签: forms validation symfony

我有一个“用户”表单:

public function buildForm(FormBuilder $builder, array $options)
{
    $builder
        ->add('email', 'repeated', array(
            'type' => 'email',
            'first_name' => 'Email',
            'second_name' => 'Confirm Email',
            'invalid_message' => 'The email addresses you entered did not match.',
            'error_bubbling' => true
        ))
        ->add('password', 'repeated', array(
            'type' => 'password',
            'first_name' => 'Password',
            'second_name' => 'Confirm Password',
            'invalid_message' => 'The passwords you entered did not match.',
            'error_bubbling' => true
        ))
    ;
}

该实体具有以下验证:

/**
 * @var string $email
 *
 * @Assert\NotBlank(message="Please enter an email address")
 * @Assert\Email()
 * @ORM\Column(name="email", type="string", length=100, unique=true)
 */
private $email;

如果您在表单中输入不匹配的电子邮件地址,即使用户显然输入了某些内容,也会触发@Assert \ NotBlank错误。有没有办法在触发“重复”错误时停止显示“空白”错误?

1 个答案:

答案 0 :(得分:1)

这是一个已知问题,这是Symfony问题的门票:https://github.com/symfony/symfony/issues/2945