Cakephp输入选择多个所选问题

时间:2014-01-24 12:52:52

标签: php cakephp html-select

我有一些基本问题

    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没有打印选中的复选框,我做错了什么?

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));
相关问题