Filter Holders with Yii2

Does anyone know how to implement a placeholder or tooltip in a Gridview Yii2 Framework filter? I need something that is allocated to the user to tell them that the text field is actually a search filter.

We look forward to hearing.

Preview

+4
source share
2 answers

A placeholder can be implemented as follows:

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel'  => $searchModel,
    'columns'      => [
        [
            'attribute' => 'name',
            'filterInputOptions' => [
                'class'       => 'form-control',
                'placeholder' => 'Type in some characters...'
             ]
        ],
        ['class' => 'yii\grid\ActionColumn' ],
    ],
]); ?>

class should be provided, although it is optional - this is just the default style style.

Configure this globally

The only way I found is config / web.php, which is used to configure the application:

$config = [
    ...
    'on beforeRequest'          => function ($event) {
        Yii::$container->set('yii\grid\DataColumn', [
            'filterInputOptions' => [
                'class'       => 'form-control',
                'placeholder' => 'Type in some characters...'
            ]
        ]);
    },
    ...
];

. DataColumn . . GridView, . , .

+11

yon tooltip/title filterOptions

 [
            'attribute' => 'name',
            'label' => 'labelname',
            ...
            ....
            'filterOptions' => [ 'title' => 'prova'],
        ],
+2

All Articles