standard course module elements mandatory

standard course module elements mandatory

by Raymond Mlambo -
Number of replies: 2

Hi all,

How can I make all the standard course module elements mandatory in my activity plugin? I mean, right now, in my code, I'm just calling them using this:

$this->standard_coursemodule_elements();

But I'd need to make them mandatory in the module so that an ID Number always exists in the plugin.

How can I achieve this?

Attachment Screen Shot 2017-04-27 at 6.14.38 PM.png
Average of ratings: -
In reply to Raymond Mlambo

Re: standard course module elements mandatory

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You can just call

$mform->addRule('cmidnumber', get_string('required'), 'required', null, 'client');
after you have called standard_coursemodule_elements().

Average of ratings: Useful (1)
In reply to Tim Hunt

Re: standard course module elements mandatory

by Raymond Mlambo -

Solved! hahahahaa, joy at last!!! Thank you man, its working perfectly!!