-1

YII not updating

Tried to GOOGLE but no difference.

 public function actionEdit($id)
    {
        $model = AddMix::findOne($id);

    if($model->load(Yii::$app->request->post()) && $model->save()){

        Yii::$app->session->setFlash('detailssubmited');

        return $this->redirect(['mixes','id'=>$model->id]);
    }

    return $this->render('editmix',['model'=>$model]);
}

It does not update instead it returns same view with changed value but not in database

mufazmi
  • 720
  • 4
  • 13
  • 30

1 Answers1

2

It fail the validation so do not enter into the if and re-render the form.

New data are shown because of $model->load(Yii::$app->request->post())

check:

$model->getErrors();

see getErrors documentation

Ivan Buttinoni
  • 3,775
  • 1
  • 19
  • 33