/** {@inheritdoc} */ protected function getDefaultRules() { return array_merge(parent::getDefaultRules(), ['POST ajax' => ['save' => true, 'flash' => false, 'success' => ['class' => RenderJsonAction::class, 'return' => function ($action) { return $action->collection->models; }]], 'POST pjax' => ['save' => true, 'success' => ['class' => ProxyAction::class, 'action' => $this->pjaxView, 'params' => function ($action, $model) { return ['id' => $model->id]; }]], 'POST' => ['save' => true, 'success' => ['class' => RedirectAction::class]], 'GET' => ['class' => RedirectAction::class]]); }
/** {@inheritdoc} */ protected function getDefaultRules() { return array_merge(parent::getDefaultRules(), ['GET ajax' => ['class' => RenderAjaxAction::class, 'view' => $this->view, 'data' => $this->data, 'params' => function ($action) { $model = $action->controller->newModel(['scenario' => $action->scenario]); return ['model' => $model, 'models' => [$model]]; }], 'GET' => ['class' => RenderAction::class, 'view' => $this->view, 'data' => $this->data, 'params' => function ($action) { $model = $action->controller->newModel(['scenario' => $action->scenario]); return ['model' => $model, 'models' => [$model]]; }], 'POST ajax' => ['save' => true, 'flash' => false, 'success' => ['class' => RenderJsonAction::class, 'return' => function ($action) { return ['success' => true]; // todo: wise resulting }], 'error' => ['class' => RenderAjaxAction::class, 'view' => $this->view, 'data' => $this->data, 'params' => function ($action) { \Yii::$app->response->statusCode = 422; $error = \Yii::$app->session->removeFlash('error'); \Yii::$app->response->statusText = reset($error)['text']; return ['model' => $action->collection->first, 'models' => $action->collection->models]; }]], 'POST' => ['save' => true, 'success' => ['class' => RedirectAction::class, 'url' => function ($action) { return $action->collection->count() > 1 ? $action->controller->getSearchUrl(['id_in' => $action->collection->ids]) : $action->controller->getActionUrl('view', ['id' => $action->model->id]); }], 'error' => ['class' => RenderAction::class, 'view' => $this->view, 'data' => $this->data, 'params' => function ($action) { return ['model' => $action->collection->first, 'models' => $action->collection->models]; }]]]); }