/** * 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(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Role model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { if (!$this->is_access('role/create')) { Yii::$app->session->setFlash('error', $this->errorInfo); return $this->redirect($this->redirectUrl); } $model = new Role(); if ($model->load(Yii::$app->request->post()) && $model->addData()) { Yii::$app->session->setFlash('success', '添加成功'); return $this->redirect(['index']); } else { Yii::$app->view->params['meta_title'] = '添加角色'; // 权限节点 $RoleAction = new RoleAction(); $treeRoleList = $RoleAction->treeList(); return $this->render('create', ['model' => $model, 'treeRoleList' => $treeRoleList]); } }