Page 1 of 1

couldn't show or collect data from checkbox

PostPosted: 26. March 2010 10:42
by kwokwai
Hi all,

I am using cakePHP 1.26. in xampp 1.73 for windows.
I am building a simple page to collect data from a form and delete a specific row of data.

here is part of the source code in views/post/index.ctp:
Code: Select all
<?php echo $form->create(null,array('url' => '/cake126/post/deleting, 'type'=>'get'));?>       
<input type="checkbox" value="1" name="which[]">
<input type="checkbox" value="2" name="which[]">
<input type="checkbox" value="3" name="which[]">
<?php echo $form->end('Delete');?>



here is part of the source code in controllers/post_controller.php:
Code: Select all
function deleting() {
debug($this->data);
}


The debug function didn't show any data.

Could anyone help me out please?

Re: couldn't show or collect data from checkbox

PostPosted: 04. April 2010 02:52
by kyha29
it is easy just use this



$b_array = $_get['which'];

for ($i=0; $i<count($b_array); $i++)
{
echo $b_array[$i];
}