Disableing checkbox based on data from database in mod_form.php

Disableing checkbox based on data from database in mod_form.php

by Manoel Manev -
Number of replies: 0

Hi! Sorry if my English is not good. I have one problem. I am curently making a new Activity Module and I am making a mod_form.php file. Before that, I made a settings.php file, where I add some checkboxes, text fields, dropdowns and etc.
I have that example: In the mod_form.php I have one checkbox ("Having archive"). The admin, in the Plugin settings, choose to select the dropdown (Archive settings), which it have three options:
  • Having archive
  • Not having archive
  • Teacher chose
If the admin chooses 'having archive', in the mod_form.php the checkbox ("Having archive") should be checked and be disable.
If the admin chooses 'not having archive', in the mod_form.php the checkbox ("Having archive") should be notchecked and be disable.
And if the admin chooses 'Teacher chooses', in the mod_form.php the teacher should have the opportunity to choose whether the checkbox to be checked or not.

So the problem is that after I read about disabledIf (https://docs.moodle.org/dev/lib/formslib.php_Form_Definition), I see that this function is only working with any element or groups made from mform object. I get the data on Administration settings from  get_config() function. How to make my checkbox be disable/not disable based on having the data from the database? Thanks!!!

Average of ratings: -