Hi there,
Im new at yii and followed the tutorial guide.
I have an issue at the last step, while using Gii code generator.
The system created the code using CRUD, but it seems that it isnt working correctly. The database entries are listed and I can even add a new entry in the DB, but when I try to update, delete or view a single entry, it throws me an yii\web\BadRequestHttpException: Missing required parameters: code i error when clicking on the icon for updating, deleting or viewing
It seems like a bug in Gii’s CRUD generator.
The country/index page creates a URL of “country/view?id=SR” for the view page of “SR”, but it should be “country/view?code=SR” because the PK is ‘code’.
One quick (and dirty) workaround might be renaming the parameter of actionView():
// pubulic function actionView($code)
pubulic function actionView($id)
{
return $this->render('view', [
// 'model' => $this->findModel($code),
'model' => $this->findModel($id),
]);
}
I will examine the problem a little further. My guess is that the Gii’s CRUD generator might fail to produce the right code when the model’s PK is not ‘id’.
Thanks for your lookup on github.
It is funny that I’m the first one who trapped into that bug while doing the tutorial
Anyway, it was interesting to start with debugging eventhough I had no idea on what am I doing
I also have no idea why this bug has been hidden from many people for this long.
Has there been no one that faithfully followed the tutorial step by step before you?
Good grief.