A checkbox only holds true or false, but you are trying to store the user id in it. I'd change it to a 'selected' field and then inspect $this->data for array keys where 'selected' => true. I'd retain your user id field too (as a text field) otherwise you won't know the ids of the selected rows.
Jeremy Burns Class Outfit http://www.classoutfit.com On 20 Sep 2011, at 21:28, rockbust wrote: > I just can not figure this out. Read the book > http://book.cakephp.org/#!/view/1390/Automagic-Form-Elements > > in my user_index view I am looping through the results of the > find(all). for each pass of the foreach I want to set a checkbox so I > can mass select each user_id. I can not get the multiple checkbox to > select more than 1 checkbox (the last id). > > my view > > <?php echo $this->Form->create('MailingList', array('action'=>'/ > temp_list'));?> > > <tr> > <th><?php echo "select";?></th> > <th><?php echo > $this->Paginator->sort('first_name');?></th> > <th><?php echo > $this->Paginator->sort('last_name');?></th> > <th><?php echo $this->Paginator->sort('email');?></th> > <th><?php echo $this->Paginator->sort('dob');?></th> > <th><?php echo $this->Paginator->sort('role');?></th> > <th><?php echo $this->Paginator->sort('active');?></th> > <th><?php echo $this->Paginator->sort('created');?></th> > <th class="actions"><?php __('Actions');?></th> > </tr> > <?php > $i = 0; > foreach ($users as $user): > $class = null; > if ($i++ % 2 == 0) { > $class = ' class="altrow"'; > } > ?> > <tr<?php echo $class;?>> > <td><?php echo $this->Form->checkbox('id', array('value' => > $user['User']['id'], 'hiddenField' => false)); ?> </td> > <td><?php echo $user['User']['first_name']; ?> </td> > <td><?php echo $user['User']['last_name']; ?> </td> > <td><?php echo $user['User']['email']; ?> </td> > <td><?php echo $user['User']['dob']; ?> </td> > <td><?php echo $user['User']['role']; ?> </td> > <td><?php echo $user['User']['active']; ?> </td> > <td><?php echo $user['User']['created']; ?> </td> > <td class="actions"> > <?php echo $this->Html->link(__('View', true), > array('action' => > 'view', $user['User']['id'])); ?> > <?php echo $this->Html->link(__('Edit', true), > array('action' => > 'edit', $user['User']['id'])); ?> > <?php echo $this->Html->link(__('Delete', true), > array('action' => > 'delete', $user['User']['id']), null, sprintf(__('Are you sure you > want to delete # %s?', true), $user['User']['id'])); ?> > </td> > </tr> > <?php endforeach; ?> > </table> > > This looks fine in fine in firebug. > I have also tried several variations of below but I get a blank screen > on submit: > > <td><?php echo $this->$form->input('User.id', array('type' => > 'select', 'multiple' => 'checkbox', 'options' => array('value' => > $user['User']['id'] ))) ?> </td> > > > <td><?php echo $this->Form->input($user['User']['id'], array('type' => > 'select', 'multiple' => 'checkbox', 'label' => false, 'options' => > array('value' => $user['User']['id'] ))); ?> </td> > > Thanks Robert > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > [email protected] For more options, visit this group at > http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
