0

есть такой код

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

теперь мне надо в случае если $colorDatas не пустое мне надо добавить следующий виджет в 'columns'

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

в GridView не подскажите как этосделать

1 ответ 1

0

Формируйте предварительно список колонок, в чем проблема?

$columns = [
   // all columns from GridView::widget execution without colors
];

if ($colorDatas) {
    $columns[] = ['filter' => Select2::widget /* all code for column */]
}

GridView::widget([
    // your settings
    'columns' => $columns
]);

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.