public function actionCreate()
{
$model = $this->getModel(Rule::SCENARIO_CREATE);
if (\Yii::$app->request->isAjax && $model->load(\Yii::$app->request->post())) {
\Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($model);
}
if ($model->load(\Yii::$app->request->post()) && $model->create()) {
\Yii::$app->session->setFlash('success', \Yii::t('rbac', 'Rule has been added'));
return $this->redirect(['index']);
}
return $this->render('create', ['model' => $model]);
}