General developer forum

How to disable a select box in Moodle form

 
I Teach With Moodle
How to disable a select box in Moodle form
Particularly helpful MoodlersPlugin developersTesters

Hi, 

I have created a form that used an 'autocomplete' element, and I want to disable this select box if a checkbox found in the form is not checked. I have followed the 'disabledIf' documentation in the formslib API, but I cannot get things to work. Here is what I have so far:

$mform->addElement('autocomplete', 'weekdays', get_string('repeatevery', 'local_hwk'), $weekdays, $options);
$mform->disabledIf('weekdays', 'availablefromenabled');
$mform->addHelpButton('weekdays', 'repeatevery', 'local_hwk');
The 'availablefromenabled' is a checkbox, and I am able to get other elements on the form to be disabled based on that checkbox. I am developing for Moodle 3.3. Has anyone been able to disable this particular type of element?

Cheers, 

Fred


 
Average of ratings: -
Picture of Vitaly Filatushkin
Re: How to disable a select box in Moodle form
 

hi Fred,

I has the same issue. It looks like the bug https://tracker.moodle.org/browse/MDL-57680 is still unresolved in 3.3.1

Thanks

 
Average of ratings: -
I Teach With Moodle
Re: How to disable a select box in Moodle form
Particularly helpful MoodlersPlugin developersTesters

Hi Vitaly, 

Thank you for the link. It's good to know that there is a reason why I'm trying to do isn't working. I have reverted to using a regular select. 

Cheers, 

Fred

 
Average of ratings: -