开发者

Symfony2 forms repeated error also triggers blank error

开发者 https://www.devze.com 2023-04-11 19:12 出处:网络
I have a \"User\" form: public function buildForm(FormBuilder $builder, array $options) { $builder ->add(\'email\', \'repeated\', array(

I have a "User" form:

public function buildForm(FormBuilder $builder, array $options)
{
    $builder
        ->add('email', 'repeated', array(
            'type' => 'email',
            'first_name' => 'Email',
            'second_name' => 'Co开发者_运维百科nfirm 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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消