Answer the question
In order to leave comments, you need to log in
How to display validation errors from multiple forms in yii2?
There are 2 forms on one page. How to make these 2 forms display errors to the user in case of incorrect data?
if ($modelLog->load(Yii::$app->request->post()) && $modelLog->validate() &&
$model->load(Yii::$app->request->post()) && $model->validate())
{
...
}
Answer the question
In order to leave comments, you need to log in
This is because the and-condition check doesn't go beyond the first false it encounters (in your case, $modelLog->validate()).
To validate both forms at once, modify the validation logic. Something like
$isValid1 = $modelLog->validate();
$isValid2 = $model->validate();
if ($isValid1 && $isValid2) {...}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question