以下代码将在yii框架的Controller中分别显示chekckBoxColumns的空数组。 任何想法,我做错了什么?
这是GridView的代码
<?=
Html::beginForm(['/mail/mail-eingang/deleteallmails'], 'post', ['name' => 'document']);
?>
<p>
<?= Html::submitButton('Delete', ['name' => 'button_checkBoxes', 'title' => 'Löscht alle ausgewählten Mails']); ?>
</p>
.
.
$gridColumn = [
.
.
[
'class' => '\kartik\grid\CheckboxColumn', 'checkboxOptions' => function($model) {
return ['value' => $model->id];
},
],
];
?> <?=
Html::endForm();
这是控制器
public function actionDeleteallmails() {
$checkbox = (array) Yii::$app->request->post('selection');
print_r("var_dump of post:<br>");
var_dump(Yii::$app->request->post());
print_r("<br><br>var_dump of POST[button_checkBoxes]:<br>");
var_dump($_POST['button_checkBoxes']);
print_r("<br><br>var_dump of post(selection):<br>");
var_dump(Yii::$app->request->post('selection'));
print_r("<br><br>var_dump of checkbox:<br>");
var_dump($checkbox);
die();
}
控制器会给我以下结果:
var_dump of post:
array(3) { ["_csrf-frontend"]=> string(88) "aOy2kVhHjxM_Q40lq4Cfs-izrPeqhVDXxwcjO-HAxmAOuc7LOSzKf1EOoGfo4ffWsNHnws2yIYb1U2JQq_miVw==" ["button_checkBoxes"]=> string(0) "" ["MailEingangSearch"]=> array(5) { ["id"]=> string(0) "" ["mail_adresse_absender"]=> string(0) "" ["betreff"]=> string(0) "" ["bodytext"]=> string(0) "" ["gelesen"]=> string(0) "" } }
var_dump of POST[button_checkBoxes]:
string(0) ""
var_dump of post(selection):
NULL
var_dump of checkbox:
array(0) { }