2011-10-06 61 views
3

我有一個「用戶」的形式:Symfony2的形式重複的錯誤也觸發空白錯誤

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錯誤。有沒有辦法阻止「空白」錯誤顯示何時觸發「重複」錯誤?

+2

,讓我們看看:https://github.com/symfony/symfony/issues/2413 –

回答