Answer the question
In order to leave comments, you need to log in
How to make a filter in GridView by a field that is not in the database?
Tell me how to make a filter by a field (type) that is not in the database, or rather it is, but for serialize'but
this field can be obtained like this
$conf = unserialize($model->conf);
$type = $conf['type'];
[
'attribute' => 'type',
'value' => function ($model) {
$conf = unserialize($model->conf);
return $model->getType($conf['type']);
},
'filter' => Html::activeDropDownList(
$searchModel,
'type',
\app\modules\tour\models\TourSetting::getTypeArray(),
['class' => 'form-control', 'prompt' => 'Все']
)
],
Answer the question
In order to leave comments, you need to log in
No way. If you need to implement a search on this data, you need to bring the database structure to the correct form. Instead of serialize - linked table.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question