Yii2 Gridview bulk action using checkbox column. How to properly create checkbox column in gridview for bulk actions

To add a CheckboxColumn to the yiigridGridView, add it to the columns configuration as follows:
'columns' => [
// ...
'class' => 'yiigridCheckboxColumn',
// you may configure additional properties here
This is the view:
<?=Html::dropDownList('action','',[''=>'Mark selected as: ','c'=>'Confirmed','nc'=>'No Confirmed'],['class'=>'dropdown',])?>
<?=Html::submitButton('Send', ['class' => 'btn btn-info',]);?>
'dataProvider' => $dataProvider,
'columns' => [
['class' => 'yiigridCheckboxColumn'],
]); ?>
<?= Html::endForm();?>
This is the controller:
public function actionBulk(){
foreach($selection as $id){
=Evento::findOne((int)$id);//make a typecasting
//do your stuff

1 comment

Leave a comment

Your email address will not be published. Required fields are marked *