/** * Creates a new Author model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Author(); $request = Yii::$app->request; if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index']); } else { $data = ['model' => $model]; if ($request->isAjax) { return $this->renderAjax('create', $data); } return $this->render('create', $data); } }