load method doesn't work with filtered $_POST

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

Please refer this URL for your purpose.

Here you can find that $model->load method checks on the basis of form name, defined by $model->formName() method.

Let me know if you face any query/concern regarding this.


Thank you Saurabh for the informative link. Indeed, it looks for the appropriate index inside the POST parameters. Kind regards.