Symfony2 forms repeated error also triggers blank error

I have a "User" form:

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
        ))
    ;
}

The entity has the following validation:

/**
 * @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;

If you enter mismatched email addresses in the form, the @Assert\NotBlank error is also triggered, even though the user obviously entered something. Is there a way to stop the "blank" error from showing when a "repeated" error is triggered?

Upvotes: 3

Views: 1780

Answers (1)

unairoldan
unairoldan

Reputation: 2863

it is a known issue, this is the ticket on Symfony Issues: https://github.com/symfony/symfony/issues/2945

Upvotes: 1

Related Questions