我有一些基本问题
echo $this->Form->select('Already.alredyselected',$listnom,array(
'multiple' => 'checkbox',
'label' => 'Text Label',
'selected' => $alreadyinvites,
'class' => 'selbox'));
我的阵列是:
$alreadyinvites = Array(
[258] => Banana Voadora
[196] => Jack Bob Rodrigo Silva Junior)
和
$listnom = Array(
[258] => Banana Voadora
[196] => Jack Bob Rodrigo Silva Junior
[259] => Toucinho Defumado
)
但CakePHP 2.4或2.3.2没有打印选中的复选框,我做错了什么?
答案 0 :(得分:2)
尝试
$alreadyinvites = array(258, 196);
和
echo $this->Form->select('Already.alredyselected',$listnom,array(
'multiple' => 'checkbox',
'label' => 'Text Label',
'value' => $alreadyinvites,
'class' => 'selbox'));
答案 1 :(得分:0)
试试这个:
$selected = array(2, 3);
$options = array(1, 2, 3, 4);
echo $this->Form->input('Attendees', array('multiple' => true, 'options' => $options, 'selected' => $selected));