Tuesday, September 20, 2011

multiple select box. automagic form helper problem

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)); ?>&nbsp;</td>
<td><?php echo $user['User']['first_name']; ?>&nbsp;</td>
<td><?php echo $user['User']['last_name']; ?>&nbsp;</td>
<td><?php echo $user['User']['email']; ?>&nbsp;</td>
<td><?php echo $user['User']['dob']; ?>&nbsp;</td>
<td><?php echo $user['User']['role']; ?>&nbsp;</td>
<td><?php echo $user['User']['active']; ?>&nbsp;</td>
<td><?php echo $user['User']['created']; ?>&nbsp;</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'] ))) ?>&nbsp;</td>


<td><?php echo $this->Form->input($user['User']['id'], array('type' =>
'select', 'multiple' => 'checkbox', 'label' => false, 'options' =>
array('value' => $user['User']['id'] ))); ?>&nbsp;</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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate