Symfony 2 form repeated validation in Entity with annotation
- by Sukhrob
My question is "How can I do form repeated validation in Entity with annotation?". I have an Account entity with (email, password and confirmPassword) attributes. When a new user registers a new account, he/she has to fill in email, password and confirmPassword fields. Obviously, password and confirmPassword fields must match. I saw an example of this validation with pure php (form builder) in Stachoverflow like below.
$builder->add('password', 'repeated', array(
'type' => 'password',
'first_name' => 'Password',
'second_name' => 'Password confirmation',
'invalid_message' => 'Passwords are not the same',
));
But, this is not what I want. I want this functionality with annotation in my Account entity. Maybe
* @Assert\Match(
* matchField = "password",
* message = "The password confirmation does not match password."
* )
protected $confirmPassword;