CakePHP 2.0 Select form Mulitple selected

被刻印的时光 ゝ 提交于 2019-12-01 19:04:54

Ok found a way, appearantly it needs to be like this:

$selected = array(2, 3);
$options = array(1, 2, 3, 4);

echo $this->Form->input('Attendees', array('multiple' => true, 'options' => $options, 'selected' => $selected));

Will output:

  • 1
  • 2
  • 3 checked
  • 4 checked

The $selected checks the index key of each element rather the value itself.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!