Shailesh Yadav
Shailesh Yadav

Reputation: 205

how give placeholder to dropdown box created in yii2 gridview

I have created a dropdown in yii2 gridview in search box as

[
    'attribute'=>'attribute name',
    'filter'=>array("ID1"=>"Name1","ID2"=>"Name2"),
],

I tried many ways to give placeholder but cant... so how to add placeholder??

Upvotes: 3

Views: 1119

Answers (2)

Insane Skull
Insane Skull

Reputation: 9358

Use filterInputOptions

[
   'attribute'=>'attribute name',
   'filter'=>array("ID1"=>"Name1","ID2"=>"Name2"),
   'filterInputOptions' => [
       'class' => 'form-control',         
       'prompt' => 'Select Option'
    ],
],

Upvotes: 6

Juragan Palsu
Juragan Palsu

Reputation: 96

Try it,,

[
    'attribute'=>'attribute name'
    'filter' =>  Html::activeDropDownList($searchModel, 'attribute name', array("ID1"=>"Name1","ID2"=>"Name2"),['class'=>'form-control','prompt' => 'Select Name']),
]

Hope help,,,

Upvotes: 0

Related Questions