/** * Creates a new EntityType model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new EntityType(); if ($model->load(Yii::$app->request->post()) && $model->save()) { if (Yii::$app->request->isAjax) { header('Content-type: application/json'); echo Json::encode(['status' => 'DONE', 'model' => $model]); exit; } else { return $this->redirect(['view', 'id' => $model->id]); } } else { return $this->renderAjax('create', ['model' => $model]); } }