Model->Save Problem

Guys,

I have this code on my update section of CRUD.

Everything worked fine but now it insert new record instead of update the existing one.




$model = Yii::createObject(['class' => $modelClassName]);

$model = $model->findOne($id);

if($id === null || $model === null)

   throw new \yii\web\HttpException('404');

if($model->load($_POST) && $model->save()){

   Yii::$app->session->setFlash('success', 'Saved');

   $model = Yii::createObject(['class' => $modelClassName]);

}



Also $model->isNewRecord is false before $model->load($_POST) && $model->save()

My mistake.

I’m sending form to different Action.