Display status selectbox as Active or Not-Active in YII2 Gridview


(chinaka) #1

this is what i have done so far in my gridview,

in the database status values are stored as 0 and 1, while 0 is for inactive and 1 for active

[
‘attribute’ => ‘status’,
‘label’ => ‘Status’,
‘value’ => function ($model){
return $model->status?‘Active’:‘Not-Active’;
},
‘filter’=>array(),
],


Display the state name for each transaction in the transaction Gridview index.php
(Femi) #2

[
‘attribute’ => ‘status’,
‘label’ => ‘Status’,
‘value’ => function ($model){
return $model->status==1?‘Active’:‘Not-Active’;
},
],


(chinaka) #3

Yea i get but the filter needs to have be a selectbox, with what you did it shows a textbox.