I have a classic form with fields : 'username', 'password' and 'birthday'.
Here are my asserts for validation (in my User entity) :
.....
/**
* @var string
* @Assert\NotBlank(message="username.error.blank")
* @Assert\MinLength(limit="2", message="username.error.short")
*/
protected $username;
/**
* @var string
* @Assert\NotBlank(message="password.error.blank")
* @Assert\MinLength(limit="4", message="password.error.short")
*/
protected $password;
/**
* @Assert\True(message="password.error.different")
*/
public function isPasswordLegal()
{
return ($this->username != $this->password);
}
The problem is that when I submit the form when it is totally empty :
- 'username' : error message because it is blank (ok)
- 'password' : error message because it is blank (ok)
- 'password' : error message because it is the same as username (here is the problem !)
So, 2 questions :
- How to solve this 'display' problem ?
- How to display this message next to 'password' field with the {{ form_errors(form.password) }} ?
Thanks for your help :-)
Aurel