public function actionDelete() { $category_id = null; if (\Yii::$app->request->isGet && ($category_id = \Yii::$app->request->get('id'))) { if ($this->model->remove($category_id)) { jump_success(t_arr('app', ['delete', 'success'], '', '!')); } else { jump_error($this->model->getFirstError('category_id') ?: $this->model->getFirstError('error')); } } }
public function addChild($parms) { $this->setScenario(self::SCENARIO_CREATE); if ($this->load($parms) && $this->validate()) { $auth = \Yii::$app->authManager; $this->childType = $parms[self::formName()]['childType']; $parent = $auth->getRole($this->parent); if ($this->childType == 1) { $child = $auth->getRole($this->child); } else { $child = $auth->getPermission($this->child); } if (!$child) { $this->addError('child', t_arr('app', ['child', 'node', 'not', 'exists'], '', '!')); return false; } return $auth->addChild($parent, $child); } }
<?php use yii\helpers\Html; ?> <!-- 添加角色 --> <?php $form = \yii\widgets\ActiveForm::begin(['options' => ['class' => 'p20']]); ?> <?php ?> <h3><?php echo t_arr('app', ['user', 'role', 'edit'], '', ':'); ?> <?php echo $user->username; ?> </h3> <?php echo $form->field($model, 'user_id')->textInput(['placeholde' => 'placeholde', 'value' => $user->id]); ?> <?php echo Html::checkboxList($model->formName() . '[item_name][]', $assignMentSelectArray, $allRolesArray); ?>
<?php use yii\helpers\Html; ?> <?php $form = \yii\bootstrap\ActiveForm::begin(['options' => ['class' => 'p20']]); ?> <h3 class=""><?php echo t_arr('app', ['role', 'edit', '']); ?> </h3> <?php echo $form->field($model, 'name')->textInput(['placeholder' => '请输入角色英文名', 'readonly' => 'readonly']); echo $form->field($model, 'description')->textInput(['placeholder' => '请输入角色中文注释']); ?> <?php echo Html::submitButton(Yii::t('app', 'update'), ['class' => 'btn btn-primary']); $form->end();
public function actionRole_child_delete() { $parent = $child = null; $model = new Auth_item_child(); if (\Yii::$app->request->isGet && ($parent = \Yii::$app->request->get('parent')) && ($child = \Yii::$app->request->get('child'))) { $parent = urldecode($parent); $child = urldecode($child); if ($model->deleteChild($parent, $child)) { jump_success(t_arr('app', ['delete', 'success'], '', '!')); } } $error = $model->getFirstError('error') ?: t_arr('app', ['delete', 'fail'], '', '!'); jump_error($error); }