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