2016-03-30 48 views
0

我試圖禁用此CakePHP的組合:如何禁用CakePHP表單組合?

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

當我點擊這個複選框:

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

我試圖添加屬性 '禁用' 和「只讀'in every combo element

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

¿是否有任何方法禁用組合?我寧願選擇一個JS程序,但每個答案都是值得歡迎的!

謝謝你們!

回答

0

我能找到一個替代的回答:我把一個「DIV」的上方和內部插上這個類:

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

用下面的代碼

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

更換您的關鍵資源投入

And in JavaScript

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