Tlopasha Tlopasha - 8 months ago 119
PHP Question

GridView::FILTER_SELECT2 dont work

I try to use SELECT2 as a filter for a column but it didn't render!

This is my code :

use yii\helpers\Html;
use yii\widgets\LinkPager;
use yii\widgets\ListView;
use yii\data\ActiveDataProvider;
use kartik\grid\GridView;
use yii\widgets\Pjax;
use yii\helpers\Url;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use app\models\country;
echo GridView::widget([
'columns' => [
['attribute' =>'id','filter'=>GridView::FILTER_SELECT2],
'dataProvider'=> $dataProvider,
'filterModel' => $searchModel,


and than I get this result in browser:


Answer Source

It should be filterType instead of filter.

['attribute' => 'id', 'filterType' => GridView::FILTER_SELECT2]