Yii2:如何将 All 选项添加到 GridView 过滤器?

Rob*_*ini 1 gridview widget filter yii2

我有一个带有使用 Yii2 制作的 index.php 文件过滤器的 GridView。它显示了这个选项:

  • 空白的
  • 西

Sí 和 No 在西班牙语中是 Yes 和 No 的意思。我需要向世界展示All而不是空白选项:

GridView 显示过滤器(选项:空白、是和否)

<?= 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}'
        ],
    ],
]) ?>
Run Code Online (Sandbox Code Playgroud)

小智 5

添加属性“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
Run Code Online (Sandbox Code Playgroud)