General developer forum

 
 
Gareth J Barnard
Optionality in Moodle forms with a group.
Group DevelopersGroup Particularly helpful Moodlers

Hi,

I have the following code for MDL-37490:

$name = get_string('duedate', 'assign').$OUTPUT->help_icon('duedate','assign');
$duedateelements[] = $mform->createElement('date_time_selector', 'duedate', $name, array('optional'=>true));
$mform->setDefault('duedate', time()+7*24*3600);

$duedateelements[] = $mform->createElement('checkbox', 'displayduedate', null, get_string('displayduedate', 'assign'));
$mform->setDefault('displayduedate', 0);

$mform->addGroup($duedateelements, 'duedategrp', $name, null, false);

Which creates the 'Due date' on the attached screen shot.

However the 'optionality' no longer works.  

Note: I've had to use the method 'createElement' because of 'addGroup'. The 'addHelpButton' has been replaced with a call to $OUTPUT as calling 'addHelpButton' results in an error when used with 'createElement' instead of 'addElement' and if I use 'addElement' then the elements are duplicated. There is no 'createHelpButton' method available.

Please can anybody point me in the right direction or suggest a fix.

Many thanks,

Gareth


 
Average of ratings: -
Gareth J Barnard
Re: Optionality in Moodle forms with a group.
Group DevelopersGroup Particularly helpful Moodlers

Cracked it using 'disabledIf'.  Thanks to all those who read the post.  Details on the above tracker.

Cheers,

Gareth

 
Average of ratings: -