protected function findModel($id) { if (($model = Role::getRoleByName($id)) !== null) { return new ActiveRecordAdapter($model); } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<div class="user-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'username')->textInput(); ?> <?php echo $form->field($model, 'email')->textInput(); ?> <?php if (\yii::$app->getUser()->can("rbac/roles/update")) { echo $form->field($model, 'role')->dropDownList(Role::getAllRolesForDropdown()); } if (\yii::$app->getUser()->can("users/usercontroller/update")) { echo $form->field($model, 'status')->dropDownList(User::getUserStatusList()); } ?> <?php echo $form->field($model, 'password')->passwordInput(); ?> <?php echo $form->field($model, 'image')->widget(Kcfinder::className()); ?> <?php echo $form->field($model, 'file_collection_id[]')->widget(Kcfinder::className(), ['multiple' => true]);