Answer the question
In order to leave comments, you need to log in
How to use $model->getErrors() in an exception?
in fact, the whole question is, someone has their own secrets, let's say this code
if($model->save())
throw new \RuntimeException($model->getErrors());
'Title'=>[
0=> ' поле Title должно быть строкой']
Answer the question
In order to leave comments, you need to log in
the question is why exactly \RuntimeException
?
i wrote a widget, inserted it into crud generator and forgot about this problem. I just display $model->getErrors()
it in the view, through the standard bootstrap alert (actually a little different, which is in adminLTE).
But if you want globally and through errors, then you can make your own base model and put this method in afterValidate and then inherit all models from it. Well, or how to connect the behavior.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question