
In Yii2 now you are allow pass an array as param to gridview column for display the data. Below is the example how to pass array to gridview column.
Exmaple:
The $status is an array and $data is the model results.
'content' => function($data) use ($status) {
return (isset($status[$data->status]) ? $status[$data->status] : $data->status);
},
Complete Example:
= GridView::widget([
'dataProvider' => $model->search(),
'filterModel' => $model,
'showOnEmpty'=>true,
'columns' => [
'id',
'name',
[
'attribute' => 'status',
'filter' => $status,
'content' => function($data) use ($status) {
return (isset($status[$data->status]) ? $status[$data->status] : $data->status);
},
],
],
]); ?>