public function actionRoleList($id = 0) { if ($id) { return Role::findOne($id)->name; } else { return $this->_list(new Role(), 'role-list'); } }
use backend\helpers\views\Html; use backend\models\rbac\Role; $form = ActiveForm::begin(); ?> <table> <?php echo $form->field($model, 'id')->hiddenInput()->label(false); ?> <?php echo $form->field($model, 'username'); ?> <?php echo $form->field($model, 'new_password')->passwordInput(); ?> <?php echo $form->field($model, 'password_repeat')->passwordInput(); ?> <?php echo $form->field($model, 'role')->dropDownList(Role::getAllRoles()); ?> <div class="btns"><?php echo Html::submitButton('提交', ['class' => 'btn']); ?> </div> </table> <?php ActiveForm::end();