A
A
akula222017-02-14 07:37:51
Yii
akula22, 2017-02-14 07:37:51

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'];

at the moment the gridview is designed like this
[
 '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' => 'Все']
 )
 ],

Now it remains to resolve in SearchModel'i, tell me how?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2017-02-14
@webinar

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 question

Ask a Question

731 491 924 answers to any question