formslib in Moodle 2.0 - documentation?

formslib in Moodle 2.0 - documentation?

by Howard Miller -
Number of replies: 3
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I assume (seeing as I can no longer get it to work) that Moodle 2.0 has had some significant - and afaik undocumented changes. Help?

For example... (taken from the completion report, but I don't think that matters)


$form = new course_completion_form('completion.php?id='.$id, compact('course'));


The class that instantiates doesn't have a constructor so those parameters must be handled by the base forms class. That's new though - and (I fear) not documented. What do they do...

The actual form definition class now has picked up some extra mysteries such as...


$course = $this->_customdata['course'];


What is "_customdata" ??

Did anybody document anything? wink


Average of ratings: -
In reply to Howard Miller

Re: formslib in Moodle 2.0 - documentation?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Oh... I apologise, sort of. That stuff was it 1.9. It never seems to have found it's way into the docs smile
In reply to Howard Miller

Re: formslib in Moodle 2.0 - documentation?

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

Well, _customdata is just some random data, and it is really up to the subclass to decide what data it wants to store there, and what it wants to do with it. Sometimes there is some data that it would be very useful to have access to in the definition() method, and so being able to pass it in as $customdata when you construct the form, and then access it as $this->_customdata is helpful.

In reply to Tim Hunt

Re: formslib in Moodle 2.0 - documentation?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Tim,

It's just me being an idiot. I don't seem to use the formslib very often and it always turns into a banging my head off the wall session when I do. I keep trying to think of a way of making it clearer in the docs, but it's really just one of those "you have to get all the little bits right" things.

The subject of passing data into your form subclass is obviously quite important and some "best practice" advice in the documentation page wouldn't hurt at all as there are obviously some options here.