/** * @return array|string */ public function actionCreate() { $model = new TourRecord(); $model->setScenario('create'); $request = Yii::$app->request; if ($model->load($request->post())) { if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($model); } if ($model->save()) { return $this->redirect(['tour/index']); } } return $this->render('create', ['model' => $model]); }