Hello, this is a typical update code for a controller generated by Gii:
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
Would someone please explain why the $model->load method fails when you set the parameter name of $_POST? Like this:
...
if ($model->load(Yii::$app->request->post('ModelName')) && $model->save()) {
...
That should work according to this documentation example.
-
operating system: Windows
-
Web server: Apache
-
browser type: Firefox 37
-
Yii version: 2.0.4
-
PHP: 5.5