/** * Creates a new Order model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($store_id = null) { if ($store_id == null) { return $this->render('store_list', ['stores' => $this->subData['userStores']]); } $this->setSubData(); $model = new Order(); $model->scenario = 'create'; $model->store_id = (int) $store_id; // $model->refresh(); if ($model->load(Yii::$app->request->post()) && $model->save()) { $this->calculateFormula($model); Yii::$app->session->setFlash('success', 'The record was cteated.'); return $this->redirect(['view', 'id' => $model->order_id]); } else { if (Yii::$app->request->isAjax) { return $this->renderAjax('_form', ['model' => $model, 'subData' => $this->subData]); } else { return $this->render('create', ['model' => $model, 'subData' => $this->subData]); } } }