Posted By

sveggiani on 10/07/10


Tagged

cakephp not-mine


Versions (?)

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


 / Published in: PHP
 

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

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

  1. // In the view...
  2.  
  3. // example array
  4. $test = array(
  5. 'blah' => array (0 => 'werd', 1 => 'hah'),
  6. 'woo' => array(2 => 'yay'),
  7. 'bla' => array(3 => 'hoo', 4 => 'ters'),
  8. 'asdf' => array(5 => 'asdf'), // this item won't appear in the list
  9. 'lksjldkfj' => array(6 => 'asdfasdfasdf'),
  10. );
  11.  
  12. echo $form->input('zone.id', array('options' => $zonesList, 'empty' => __('Elegí tu ciudad', true), 'class' => 'selectBox', 'showParents' => true ) ); // note the 'showParents' parameter

Report this snippet  

You need to login to post a comment.