public function run($id) { parent::run($id); $model = $this->_model; $methodParam = $this->modelMethod[1]; $methodResult = $methodParam ? call_user_func([$model, $this->modelMethod[0]], $methodParam) : call_user_func([$model, $this->modelMethod[0]]); if ($methodResult) { \Yii::$app->session->setFlash('success', $this->successMessage); return $this->controller->redirect($this->redirectUrl); } else { throw new HttpException('Операция не может быть выполнена'); } }
public function run() { parent::run(); Url::remember('', self::URL_NAME_INDEX_ACTION); $model = $this->_model; $model->load(\Yii::$app->request->get()); /** @var SearchModelInterface $model */ $dataProvider = $model->search(); $viewParams = ['model' => $model, 'dataProvider' => $dataProvider]; if (\Yii::$app->request->isPjax && $this->pjaxView !== null) { return $this->controller->renderAjax($this->pjaxView, $viewParams); } return $this->controller->render($this->view, $viewParams); }
/** * @inheritdoc */ public function run() { parent::run(); $model = $this->_model; $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()) { \Yii::$app->session->setFlash('success', $this->successMessage); return $this->controller->redirect($this->redirectUrl); } } return $this->controller->render($this->view, ['model' => $model]); }
/** * @inheritdoc */ public function run($id) { parent::run($id); $model = $this->_model; $request = \Yii::$app->request; if ($this->_model->load($request->post())) { if ($request->isAjax) { \Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($this->_model); } $methodParam = $this->modelMethod[1]; $methodResult = $methodParam ? call_user_func([$model, $this->modelMethod[0]], $methodParam) : call_user_func([$model, $this->modelMethod[0]]); if ($methodResult) { \Yii::$app->session->setFlash('success', $this->successMessage); return $this->controller->redirect($this->redirectUrl); } } return $this->controller->render($this->view, ['model' => $model]); }