I have a problem when adding a validation rule with expression in the validation config file in symfony2. The goal here is to validate if the new password matches the retype new password. my config is:
constraints:
- Expression:
expression: "this.passwordMatch()"
message: "Passwords don`t match"
and the function passwordMatch is:
public function passwordMatch() {
if(!empty($this->password)) {
return $this->password === $this->new_password_confirmed;
}
}
The function is called and its all fine until then. The $this->password and $this->new_password_confirmed are members of the entity, which i created for this form validation, but the values of them come as null. The names of the inputs and of the member variables are the same. Where is my mistake.
I dont use symfony form builder and my form is plain HTML
Hope that i explained the problem good and get an answer soon.
Thanks for the time