Forms CakePHP3.1:禁用选择输入中的选项
我想禁用选择输入中的选项,因此我尝试:Forms CakePHP3.1:禁用选择输入中的选项,forms,cakephp,html-select,disabled-input,cakephp-3.1,Forms,Cakephp,Html Select,Disabled Input,Cakephp 3.1,我想禁用选择输入中的选项,因此我尝试: echo $this->Form->select("status", [ 'options' => $status, 'value' => $order->status, 'label' => false, 'disabled' => [1, 2] ]); 但它不会在html代码中生成任何disabled语句 我的错误是什么?将属性设置为select选项的正
echo $this->Form->select("status",
[
'options' => $status,
'value' => $order->status,
'label' => false,
'disabled' => [1, 2]
]);
但它不会在html代码中生成任何disabled
语句
我的错误是什么?将属性设置为select选项的正确方法是传递如下数组
$options = [
[ 'text' => 'option 1', 'value' => 'value 1', 'disabled' => true],
[ 'text' => 'option 2', 'value' => 'value 2', 'disabled' => true],
[ 'text' => 'option 3', 'value' => 'value 3'],
[ 'text' => 'option 4', 'value' => 'value 4']
];
echo $this->Form->select(
'status',
$options,
['value' => $order->status, 'label' => false]
);
您应该使用FormHelper的输入功能并设置type=“select”
.我的样本(仅可选择三个)
您应该仔细查看文档,并检查
FormHelper::select()
的正确签名@ndm,嗯,很抱歉,我把input()
和select()
语法搞混了。工作答案+1.
$status = [1 => 'One', 2 => 'Two', 3 => 'Three'];
echo $this->Form->input("status",
[
'type' => 'select',
'options' => $status,
'label' => false,
'disabled' => [1, 2]
]
);