Return to Snippet

Revision: 33246
at October 7, 2010 05:23 by sveggiani


Updated Code
// In the view...

// example array
$test = array(
    'blah' => array (0 => 'werd', 1 => 'hah'),
    'woo' => array(2 => 'yay'),
    'bla' => array(3 => 'hoo', 4 => 'ters'),
    'asdf' => array(5 => 'asdf'), // this item won't appear in the list
    'lksjldkfj' => array(6 => 'asdfasdfasdf'),   
);

echo $form->input('zone.id', array('options' => $zonesList, 'empty' => __('Elegí tu ciudad', true), 'class' => 'selectBox', 'showParents' => true ) ); // note the 'showParents' parameter

Revision: 33245
at October 7, 2010 05:22 by sveggiani


Initial Code
// In the view...

// example array
$test = array(
    'blah' => array (0 => 'werd', 1 => 'hah'),
    'woo' => array(2 => 'yay'),
    'bla' => array(3 => 'hoo', 4 => 'ters'),
    'asdf' => array(5 => 'asdf'), // this item won't appear in the list
    'lksjldkfj' => array(6 => 'asdfasdfasdf'),   
);

echo $form->input('zone.id', array('options' => $zonesList, 'empty' => __('Elegí tu ciudad', true), 'class' => 'selectBox', 'showParents' => true ) ); // note the 'showParents' parameter

Initial URL
http://cakephp.lighthouseapp.com/projects/42648/tickets/479-form-helper-select-optgroup

Initial Description
This problem occurs when there is a duplicated name for the first level item (optgroup) and a second level item (option). The rendered select will not contain the mentioned option unless you do the following...

Initial Title
cakephp form helper (select) optgroup problem with nested options array

Initial Tags
cakephp

Initial Language
PHP