Example #1
0
use yii\grid\GridView;
use app\models\User;
use yii\grid\DataColumn;
/* @var $this yii\web\View */
/* @var $searchModel app\models\UserSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Users';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Create User', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['id', 'username', 'email:email', ['attribute' => 'status', 'filter' => User::getStatusesArray(), 'value' => 'statusName'], 'created_at:date', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
Example #2
0
?>

    <?php 
echo $form->field($model, 'full_name')->textInput(['maxlength' => true]);
?>

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

    <?php 
echo $form->field($model, 'role_id')->dropDownList(Role::getRolesArray());
?>

    <?php 
echo $form->field($model, 'status')->dropDownList(User::getStatusesArray());
?>




    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Создать' : 'Обновить', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
Example #3
0
    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Создать', ['signup'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'full_name', 'email:email', ['filter' => User::getStatusesArray(), 'attribute' => 'status', 'format' => 'raw', 'value' => function ($model, $key, $index, $column) {
    /** @var User $model */
    /** @var \yii\grid\DataColumn $column */
    $value = $model->{$column->attribute};
    switch ($value) {
        case User::STATUS_ACTIVE:
            $class = 'success';
            break;
        case User::STATUS_NOT_ACTIVE:
        default:
            $class = 'danger';
    }
    $html = Html::tag('span', Html::encode($model->getStatusName()), ['class' => 'label label-' . $class]);
    return $value === null ? $column->grid->emptyCell : $html;
}], ['class' => 'yii\\grid\\ActionColumn']]]);
?>