我有一个GridView,它带有由Yii2制成的index.php文件的过滤器。它显示了以下选项:
Sí和No在西班牙语中表示是和否。我需要向世界展示全部而不是空白选项:
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
'nombre_motivo_movimiento',
[
'attribute' => 'entrada',
'format' => 'raw',
'filter' => ['1' => 'Sí', '0' => 'No'], // The filter I want to improve.
'contentOptions' => [
'class' => 'text-center',
],
'value' => function($m){
if ($m->entrada) {
return '<span class="label label-success"><i class="fa fa-check"></span>';
}
else {
return '<span class="label label-danger"><i class="fa fa-remove"></span>';
}
}
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{update} {delete}'
],
],
]) ?>
答案 0 :(得分:2)
添加属性“ filterInputOptions”:
'filter' => ['1' => 'Sí', '0' => 'No'], // The filter I want to improve.
'filterInputOptions' => ['class' => 'form-control', 'id' => null, 'prompt' => 'Todos'], // to change 'Todos' instead of the blank option