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