Example #1
0
 /**
  * Displays homepage.
  *
  * @return mixed
  */
 public function actionIndex()
 {
     $query = Faculty::find();
     $provider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['name' => SORT_ASC]], 'pagination' => false]);
     $images = Faculty::find()->where(['is not', 'filename', null])->all();
     $images = ArrayHelper::map($images, 'id', 'filename');
     return $this->render('index', ['provider' => $provider, 'images' => $images]);
 }
Example #2
0
$form = ActiveForm::begin(['id' => 'updateForm']);
?>

<?php 
echo $form->field($model, 'username')->textInput(['maxlength' => true]);
echo $form->field($model, 'email')->textInput(['maxlength' => true]);
echo $form->field($model, 'password')->passwordInput();
echo $form->field($model, 'repassword')->passwordInput();
?>

<?php 
if (Yii::$app->user->identity->role == User::ROLE_ADMIN) {
    ?>
    <?php 
    // Список факультетов
    $faculties = ArrayHelper::map(Faculty::find()->orderBy('name')->all(), 'id', 'name');
    ?>
    <?php 
    echo $form->field($model, 'id_faculty')->dropDownList($faculties);
}
?>

<?php 
// массив для списка выбора ролей. Оставляем только роли с ключами 1 и 2
// (инспектор и локальный администратор)
$roles = array_slice(Yii::$app->params['decode']['user.role'], 1, 2, true);
echo $form->field($model, 'role')->dropDownList($roles);
echo $form->field($model, 'sendMail')->checkbox();
?>

<div class="form-group submitBlock">