Yii2 How to properly create checkbox column in gridview for bulk actions?
I need to create "bulk actions" similar to wordpress posts management, so you can for example delete multiple records at a time. This is my approach, and works fine, but I'm sure it is not the best approach, since this method is vulnerable to CSRF hacks. Checkbox column in a gridview: GridView::widget([ 'dataProvider' => $dataProvider, 'columns' => [ ['class' => 'yii\grid\CheckboxColumn'], 'id'=>'grid', 'country', ], ]); Button that fires a function <a href="#" onclick="bulkAction('p');"> The function: <script> function bulkAction(a) { var keys = $('#grid').yiiGridView('getSelectedRows');