/** * @param $params * @return ActiveDataProvider */ public function search($params) { $query = Setting::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'active' => $this->active, 'section' => $this->section]); $query->andFilterWhere(['like', 'key', $this->key])->andFilterWhere(['like', 'value', $this->value]); return $dataProvider; }
* @var yii\data\ActiveDataProvider $dataProvider */ $this->title = Module::t('settings', 'Settings'); $this->params['breadcrumbs'][] = $this->title; ?> <div class="setting-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php //echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a(Module::t('settings', 'Create {modelClass}', ['modelClass' => Module::t('settings', 'Setting')]), ['create'], ['class' => 'btn btn-success']); ?> </p> <?php Pjax::begin(); ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['id', ['attribute' => 'section', 'filter' => ArrayHelper::map(Setting::find()->select('section')->distinct()->where(['<>', 'section', ''])->all(), 'section', 'section')], 'key', 'value:ntext', ['class' => '\\pheme\\grid\\ToggleColumn', 'attribute' => 'active', 'filter' => [1 => Yii::t('yii', 'Yes'), 0 => Yii::t('yii', 'No')]], ['class' => 'yii\\grid\\ActionColumn']]]); ?> <?php Pjax::end(); ?> </div>