如何在cakephp中的多选选择菜单中选择多个选项

问题描述 投票:0回答:1

这是我的 cakephp 应用程序中的多选菜单代码:

<td><?= $this->Form->select('clothCutting['.$color.'][mtr_str]', ['23'=>'23', '67'=>'67', '24'=>'24'], ['multiple' => true, 'value' => "23", 'label' => false, 'class' => 'table-processed', 'style' => 'width:100%;']) ?></td>

它会被渲染成这样:

但它只选择一个选项。如果我想让它选择多个选项怎么办?

我尝试将我希望它选择的选项数组放入值属性中,但它不起作用。 像这样:

<td><?= $this->Form->select('clothCutting['.$color.'][mtr_str]', ['23'=>'23', '67'=>'67', '24'=>'24'], ['multiple' => true, 'value' => "[23,67]", 'label' => false, 'class' => 'table-processed', 'style' => 'width:100%;']) ?></td>

但现在它甚至没有选择一个选项:

我该怎么办?

cakephp
1个回答
0
投票

检查布料切割['.$color.'][mtr_str]选项内的数组构造,试试这个:

<td><?= $this->Form->select('clothCutting['.$color.'][mtr_str]', [23, 67, 24], ['multiple' => true, 'value' => "23", 'label' => false, 'class' => 'table-processed', 'style' => 'width:100%;']) ?></td>

这里有相关文档:

选择、复选框和单选控件的选项

© www.soinside.com 2019 - 2024. All rights reserved.