I am trying to generate CRUD
in yii2
using Gii
. I have created a model class using Gii
and it is created successfully. But When I try to create CRUD
, it gives the following error:
Class 'app\models\UserRoles' does not exist or has syntax error.
Here is the screen shot of what I am filling the form with and error:
The class UserRoles
exists and there is certainly no syntax error. I have tried this
and it doesn't work either. Help would be highly appreciated.
This because the class i gii can't revolve properly the app\models\YourClassName (i have experienced because create most of models in common\models for share the models between frontend and backend)
be sure where you have save the models (could be in backend\models)
then set the proper value in
Model Class eg:
backend\models\YourClassName
or simply
YourClassName
And do the same for Search Model Class too
In viewpath you should use a proper alias so if you are in frontent
@frontend\views\your-model-name
or (in some case) you can set the abolute path to the directory you need