Answer the question
In order to leave comments, you need to log in
How to write your own yii2 rules?
Hello,
I wrote my rules - but for some reason it does not work out.
public function rules() {
return [
['dob', 'validateBithday', 'skipOnEmpty' => false, 'skipOnError' => false],
];
}
public function validateBithday($attribute, $params)
{
if(date('Y', strtotime($attribute)) > data('Y')-18){
return $this->addError($attribute, 'You should be more years.');
}
}
Answer the question
In order to leave comments, you need to log in
public function validateBithday($attribute, $params)
{
if(<b>date('Y', strtotime($this->dob)) > date('Y')-18)</b>{
return $this->addError($attribute, 'You should be more years.');
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question