通过使用Lithium form helper,我们可以插入一个select
标签,可以选择单个项目。
样品:
echo $this->form->field('myfield', array(
'type' => 'select',
'list' => array(
'id1' => 'value1',
'id2' => 'value2',
),
)
);
现在,如果您想使用带有Select2
选项的multiple
jQuery插件,field
中的form helper
方法会尝试检索字符串中提交的值。
即使设置了multiple
选项!
非工作样本:
echo $this->form->field('myfield', array(
'type' => 'select',
'list' => array(
'id1' => 'value1',
'id2' => 'value2',
),
'multiple' => true,
)
);
答案 0 :(得分:0)
field
方法不接受提交表单中的数组值。
因此请使用select
选项在表单助手中尝试multiple
方法。
示例代码:
echo $this->form->select('myfield',
array(
'id1' => 'value1',
'id2' => 'value2',
),
array(
'multiple' => true,
)
);