Monday, February 27, 2012

Re: Form select how to build outgroups?

http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::select

Always check the documentation...

If you would like to generate a select with optgroups, just pass data in hierarchical format. This works on multiple checkboxes and radio buttons too, but instead of optgroups wraps elements in fieldsets:

<?php
$options = array(
  'Group 1' => array(
    'Value 1' => 'Label 1',
    'Value 2' => 'Label 2'
  ),
  'Group 2' => array(
    'Value 3' => 'Label 3'
  )
);
echo $this->Form->select('field', $options);

--
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

No comments: