Answer the question
In order to leave comments, you need to log in
Yii validation on dependent fields?
I can't figure out what I'm doing wrong. It seems to be doing everything right, but it gives a validation error.
It is necessary for me that when the fields of one of the dates are not empty, then the second field gives an error if it is not filled. And when the fields are empty - do not issue an error for mandatory filling
[['date_from', 'date_to'], 'required', 'when' => function() {
return $this-> date_from !== null || $this-> date_to !== null ;
}],
[['description'], 'required', 'when' => function() {
return (int) $this->status == self::STATUS_REFUSED;
}],
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question