Created
January 19, 2024 08:52
-
-
Save tguruslan/a0adecddaf1628cfc12a59ff2d860fa1 to your computer and use it in GitHub Desktop.
Показати помилку валідації моделі yii2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function action(Create|Update)(){ | |
// ... | |
// ajax | |
}else if($model->load($request->post()) && !$model->validate()) { | |
return ['title'=>'Помилка','content'=>json_encode($model->getErrors(),JSON_UNESCAPED_UNICODE),'footer'=> Html::button(Yii::t('app', 'Закрити'),['class'=>'btn btn-default pull-left','data-dismiss'=>"modal"])]; | |
}else{ | |
// no ajax | |
}else if($model->load($request->post()) && !$model->validate()) { | |
die(json_encode($model->getErrors(),JSON_UNESCAPED_UNICODE)); | |
}else{ | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment