How to add fields to the GridView?

there is such code

if(is_array($color)){$colorDatas=ArrayHelper::map($color,'id','value');}


now I need if $colorDatas not empty I need to add another widget in 'columns'

[
 'filter' =>Select2::widget ([
 'model' => $searchModel,
 'attribute' => 'color',
 'data' => $colorDatas,
 'language' => 'EN',
 'options' => ['multiple' => true,'placeholder' => Yii::t('backend','SELECT_SHOP')],
 'pluginOptions' => [
 'allowClear' => true
],
]),
 'attribute' => 'color',
 'value' => function($model){
 return $model->theGetValue($model);
}
 ],

in GridView do you know how to autodelete
July 4th 19 at 22:45
1 answer
July 4th 19 at 22:47
Solution
to output the widget in the column You can use the property content of the class column
me it interests as a filter but does not change the fact I need to insert this widget if $colorDatas not empty - vergie.Jerde commented on July 4th 19 at 22:50
if understand correctly, then something like this:
'filter' => empty($colorDatas) ? ": Select2::widget ([]), - bryana.Renn commented on July 4th 19 at 22:53
similarly 'filter' => empty($colorDatas) ? false : Select2::widget ([]), - bryana.Renn commented on July 4th 19 at 22:56

Find more questions by tags Yii