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


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.