Davey
(Davey975)
December 13, 2013, 11:28am
1
As far as i see, the yii\grid\CheckboxColumn gives all checkboxes a value of 1. How can i change this, so the value is the primary key of the model used in the Gridview?
<?php
echo GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
[
'class' => 'yii\grid\CheckboxColumn',
'checkboxOptions' => []
],
[..]
?>
I probably need to change something in the checkboxOptions?
amnah
(Jellysandwich5+1)
December 13, 2013, 3:57pm
2
Try this:
'checkboxOptions' => ["value" => $yourValue]
Davey
(Davey975)
December 16, 2013, 8:09am
3
Yes, but i want to use the primary key of the model used in the dataprovider. In Yii 1.x you could use $data->id for this for example.
amnah
(Jellysandwich5+1)
December 16, 2013, 2:03pm
4
'checkboxOptions' => function($model, $key, $index, $widget) {
return ["value" => $model->id];
},