crudrenderpartial

PHP Recoverable Error – yii\base\ErrorException Object of class yii\web\Response could not be converted to string


I use renderPartial to view CRUD in my frontend/index.php. but its giving error

PHP Recoverable Error – yii\base\ErrorException
Object of class yii\web\Response could not be converted to string 

here is code C:\xampp\htdocs\yii2-my-app\frontend\views\site\index.php

 <?= Yii::$app->runAction('/callback/create'); ?>

C:\xampp\htdocs\yii2-my-app\frontend\controllers\CallbackController.php

 public function actionCreate()
    {
        $model = new Callback();
         if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['view', 'id' => $model->id]);
        } else {    
            return $this->renderPartial('create', [
                'model' => $model,
            ]);
        }
    }

how to fix that error can anybody help?


Solution

  • public function actionCreate()
        {
            $model = new Callback();
             if ($model->load(Yii::$app->request->post()) && $model->save()) {
                 $model = new Callback();
                 return $this->renderPartial('create', [
                    'model' => $model,
                 ]);}     
        }