tklustig
(Kipp Thomas)
March 29, 2018, 11:53pm
1
Hi guys, following code will show empty array for chekckBoxColumns in Controller.Any ideas, what I do wrong?Here is code of GridView
'document']);?><p> 'btn btn-info', 'title' => 'Mails erstellen']) ?> 'btn btn-warning', 'title' => 'Mails erstellen']) ?> 'button_checkBoxes', 'title' => 'Löscht alle ausgewählten Mails']); ?> 'button-own_I search-button']) ?></p>..$gridColumn = [.. [ 'class' => '\kartik\grid\CheckboxColumn', 'checkboxOptions' => function($model) { return ['value' => $model->id]; }, ],];?> request->post('selection'); var_dump($checkbox); die(); if (empty(($checkbox)) && (isset($_POST['button_checkBoxes']))) { $session->addFlash("warning", "Selektieren sie die zu löschenden Mails über die Checkboxen"); return $this->redirect(['/mail/mail-eingang/index']); } }
Use debug to see what $_POST contains or do var_dump($Yii::$app->request->post());
tklustig
(Kipp Thomas)
March 30, 2018, 7:53am
3
Following code
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'));
die();
will give me following result:
var_dump of post:
array(3) { ["_csrf-frontend"]=> string(88) "zYK2HFpJ1b4akutUxBcEI6V8xQnSlx0pyz3XZCHUxlSr185GOyKQ0nTfxhaHdmxG_R6OPLWgbHj5aZYPa-2iYw==" ["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
And now?? How could this help me fixing my problem. need help for this!
You need create field in MailEingangSearch. For example MailEingangSearch::$checkboxes.
And past this name to CheckboxColumn:
\kartik\grid\CheckboxColumn::class, [
'name' => 'MailEingangSearch[checkboxes]'
]
Or as model:
\kartik\grid\CheckboxColumn::class, [
'model' => $yourMailEingangSearchModel,
'attribute' => 'checkboxes'
]
tklustig
(Kipp Thomas)
March 31, 2018, 12:06pm
5
You need create field in MailEingangSearch. For example MailEingangSearch::$checkboxes.
And past this name to CheckboxColumn:
\kartik\grid\CheckboxColumn::class, [
'name' => 'MailEingangSearch[checkboxes]'
]
Or as model:
\kartik\grid\CheckboxColumn::class, [
'model' => $yourMailEingangSearchModel,
'attribute' => 'checkboxes'
]
Solved problem without using CheckBoxColumn. Nevertheless, Thx for ur efforts helping me!