GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $modelSearch,
'columns' => [
'id',
[
'label' => 'Логин',
'attribute' => 'username',
],
[
'label' => 'Имя',
'attribute' => 'firstname',
],
[
'label' => 'Фамилия',
'attribute' => 'lastname',
],
[
'label' => 'E-Mail',
'attribute' => 'email',
],
],
]);
$totalCount = Yii::$app->db->createCommand('SELECT COUNT(*)
FROM Users
Where validation_email=:status', [':status' => 'confirmed'])
->queryScalar();
$sql = 'SELECT * FROM Users Where validation_email=:status';
$dataProvider = new SqlDataProvider([
'sql' => $sql,
'params' => [':status' => 'confirmed'],
'totalCount' => (int)$totalCount,
'sort' => [
'attributes' => [
'id',
'username',
'lastname',
'firstname',
'email',
],
],
'pagination' => [
'pageSize' => 10,
],
]);
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<div class="col-xs-3"><?= $form->field($model, 'text') ?></div>
<div class="col-xs-3"><?= $form->field($model, 'cat') ?></div>
<div class="col-xs-3"><?= $form->field($model, 'status')->dropDownList($model->getStatusList(),['prompt'=>''])
?></div>
<div class="col-xs-3"><?= $form->field($model, 'email') ?></div>
<div class="form-group col-xs-12">
<?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?>
<?= Html::a(Yii::t('app', 'Создать Запрос'), ['create'], ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
public function actionIndex()
{
$searchModel = new RequestSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}