can you help me with this? I did read the docu but the rule is still not working. Did I done it wrong? I still searching for some examples but still nothing happened. I want to validate a user's password and repeat_password if they match.
this is my code in model. that two are declared as required too on that scenario.
[['password','password_repeat'], 'checkPassword', 'on'=>'create'],
the scenario is declared on actionCreate too.
public function checkPassword($attributes, $params)
{
if(!$this->password_repeat === $this->password)
{
$this->addError($attribute, 'Passwords do not match!');
}
}
I did try using compare validation on that two fields but it won't satisfy me. If you only compare one field, it won't validate the other field. if you validate them both, there's still a possibility that they contrast each other when you delete what you have entered on one of the two fields. So I want to create one that even you delete what you have enter on that two fields, who goes first or not, they will be validated. sorry for the trouble. I hope you still get what I want to happens. Thanks.
PS, I don't want to use a password validator widget(?). thank you.
$attributeswhich should be$attribute.$this->password_repeat !== $this->password