Пример #1
0
 /**
  * Creates a new Role model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Role();
     $permissions = ArrayHelper::getValue(Yii::$app->request->post(), 'Role.permissions', []);
     $permissions = is_array($permissions) ? $permissions : [];
     $roles = ArrayHelper::getValue(Yii::$app->request->post(), 'Role.roles', []);
     $roles = is_array($roles) ? $roles : [];
     if ($model->load(Yii::$app->request->post()) && $model->createRole($permissions, $roles)) {
         return $this->redirect(['view', 'name' => $model->name]);
     } else {
         return $this->render('create', ['model' => $model, 'permissions' => $model->getPermissions(), 'roles' => $model->getRoles()]);
     }
 }