Beispiel #1
0
 /**
  * Updates an existing Role model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     if (!$this->is_access('role/update')) {
         Yii::$app->session->setFlash('error', $this->errorInfo);
         return $this->redirect($this->redirectUrl);
     }
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post()) && $model->addData()) {
         Yii::$app->cache->delete('role_list_' . $id);
         // 删除缓存
         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('update', ['model' => $model, 'treeRoleList' => $treeRoleList]);
     }
 }