controllers/RuleController.php
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,
        ]);
    }
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,
        ]);
    }
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 , ] ) ; }
Shows page where new rule can be added.

@return array|string
Shows page where new rule can be added .