Hey everyone,
I’m trying to create a little CRUD application using this tutorial
Everything but the update and delete function is working. When I click the onto "update", I am getting the following error:
When I click onto "delete", I am getting this error:
These are my SiteController functions:
public function actionDelete($id=NULL)
{
$model = $this->loadModel($id);
if (!($model->delete()))
{
Yii::$app->session->setFlash('error', 'Unable to delete model');
}
$this->redirect(\Yii::$app->urlManager->createUrl('site/index'));
}
public function actionSave($id=NULL)
{
if ($id == NULL)
{
$model = new Crud;
} else {
$model = $this->loadModel($id);
}
if(isset($_POST['Crud']))
{
$model->load($_POST);
if ($model->save())
{
Yii::$app->session->setFlash('success', 'Model has been saved');
$this->redirect(['save', 'id' => $model->id]);
} else {
Yii::$app->session->setFlash('error', 'Model could not be saved');
}
}
echo $this->render('save',['model' => $model]);
}
private function loadModel($id)
{
$model = Crud::find($id);
if ($model == NULL)
{
throw new HttpException(404, 'Model not found');
}
return $model;
}
Does anyone know what I am doing wrong? Thanks in advance!