Hi,
I’m trying to use Kartik’s widget Select2 as filter Input. Filtering works fine, but after reload dataProvider in select2 I’ve got placeholder and not selected value. Below is code I’m using in my view file. I don’t post any controller or models/searchModels code becouse I think it is irrelevant (also searching and filtering works fine). Could you guide me to right config of this extnsion?
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
// other columns
[
'attribute' => 'type',
'value' => function($model){
/* @var $model app\models\Object */
return $model->typeNames()[$model->type];
},
'filter' => Select2::widget([
'name' => 'ObjectSearch[type]',
'data' => Object::typeNames(),
'theme' => Select2::THEME_BOOTSTRAP,
'hideSearch' => true,
'options' => [
'placeholder' => 'Wybierz typ obiektu...',
// I've tried something like below but I'don't like this solution. Also it doesn't work.
'value' => isset($_GET['ObjectSearch[type]']) ? $_GET['ObjectSearch[type]'] : null
]
]),
'contentOptions' => [
'style' => 'vertical-align: middle;'
]
],
// other columns
],
]); ?>
Thanks for your help,
Kamil