如何禁用 CakePHP 表单组合?

How to disable CakePHP Form Combo?

我正在尝试禁用此 CakePHP 组合:

echo $this->Form->input('backupid', array('options' => $users_backup, 'class'=>'autocompletar', 'empty' => true, "label"=>__('Backup'), 'id' => 'cmbBackup'));

当我点击这个复选框时:

echo $this->Form->input('criticalresource');

我尝试在每个组合元素中添加 属性 'disabled' 和 'readonly'

The following image contains part of my DOM where you can see the Checkbox and the Combobox :

¿有什么方法可以禁用该组合吗?我更喜欢 JS 程序,但欢迎大家回答!

谢谢大家!

我可以找到另一个答案:我会在上面放一个 'div',然后在里面插入这个 class:

.disabledbutton {
    pointer-events: none;
    opacity: 0.4;
}

用以下代码替换您的关键资源输入

echo $this->Form->input('criticalresource',array('onclick'=>'disableCombo();'));

并且在JavaScript

<script>
function disableCombo()
{
    var cmbBackup = document.getElementById("cmbBackup");
    cmbBackup.attr('disabled','disabled');
}
</script>