Example #1
0
 /**
  * @return array|string
  */
 public function actionCreate()
 {
     $model = new HotelRecord();
     $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(['hotel/index']);
         }
     }
     return $this->render('create', ['model' => $model]);
 }