Если вы хотите получить ключи в контроллере
Пример:
<?=Html::beginForm(['Gridselected'],'post');?>
<?= GridView::widget([
'id' => 'griditems',
'dataProvider' => $dataProvider,
'columns' => [
'id',
[
'label' => 'จำนวน',
'value' => function ($model, $key, $index) {
return Html::textInput("od_amount[$key]", null, ['id' => "od_amount[$key]"]);
},
'format' => 'raw'
],
//...
['class' => 'yii\grid\CheckboxColumn'],
],
]); ?>
<?=Html::submitButton('Send', ['class' => 'btn btn-primary']);?>
<?= Html::endForm();?>
В контроллере:
public function actionGridselected(){
if ( Yii::$app->request->post() ) {
$select = (array)Yii::$app->request->post('selection'); //checkbox (array)
$odAmount=(array)Yii::$app->request->post('od_amount');
$Provider = new \yii\data\ActiveDataProvider([
'query' => yourModel::find()->->where(['id' => $select]),
]);
// for Example: Print all the amount of inputs that are checked (in checkboxcolumn)
foreach ($odAmount as $key => $value) {
if (in_array($key, $arr_select)){
$od_value[] = $value;
}
}
print_r($od_value);
}
}