cakephp form helper(select)optgroup嵌套选项数组问题

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了cakephp 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

以上是关于cakephp form helper(select)optgroup嵌套选项数组问题的主要内容,如果未能解决你的问题,请参考以下文章

CakePHP-通过widget helper查看邮件

如何从 Cakephp4 中的 Helper 获取 $this->request->getAttribute('csrfToken')?

不能用cakePHP html helper添加css版本控制

CakePHP HTML Helper添加前缀URL

CakePHP导入帮助程序

ruby form_helper.rb