Reputation: 191
The following is the controller code that seems to be working through the if statement but the data in the db is not updating.
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($_model = Yii::$app->request->post() && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
I suspect the problem lies in something to do with the fact that it is part of a CRUD code for of users and the form only updates a handful of fields (excluding password, authKey, etc).
Please help.
Thanks
Upvotes: 2
Views: 9151
Reputation: 655
Change your code from
if ($_model = Yii::$app->request->post() && $model->save()) {
to :
if ($model->load(Yii::$app->request->post()) && $model->save()) {
Upvotes: 4