How to disable CakePHP Form Combo?

55 Views Asked by At

I'm trying to disable this CakePHP combo:

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

When I click this Checkbox:

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

I've tried to add the property 'disabled' and 'readonly' in every combo element

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

¿Is there any way to DISABLE that combo? I'd rather prefer a JS procedure, but every answer is welcome!

Thank you guys!

2

There are 2 best solutions below

0
Pedro Bezanilla On BEST ANSWER

I could find an alternative answer: I'll put a 'div' above and insert this class inside:

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

Replace your critical resource input with the following code

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

And in JavaScript

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