Moodle APIs
3.8
Moodle 3.8.6 (Build: 20201109)
|
formslib.php - library of classes for creating forms in Moodle, based on PEAR QuickForms. More...
Classes | |
class | moodleform |
Wrapper that separates quickforms syntax from moodle code. More... | |
class | MoodleQuickForm |
class | MoodleQuickForm_Renderer |
MoodleQuickForm renderer. More... | |
class | MoodleQuickForm_Rule_Required |
Functions | |
if($CFG->debugdeveloper) moodle_page | form_init_date_js () |
Initalize javascript for date type form element. More... | |
pear_handle_error ($error) | |
Callback called when PEAR throws an error. More... | |
Variables | |
object | $GLOBALS ['_HTML_QuickForm_default_renderer'] = new MoodleQuickForm_Renderer() |
$GLOBALS['_HTML_QuickForm_default_renderer'] | |
const | EDITOR_UNLIMITED_FILES -1 |
setup.php includes our hacked pear libs first More... | |
formslib.php - library of classes for creating forms in Moodle, based on PEAR QuickForms.
To use formslib then you will want to create a new file purpose_form.php eg. edit_form.php and you want to name your class something like {modulename}_{purpose}_form. Your class will extend moodleform overriding abstract classes definition and optionally defintion_after_data and validation.
See examples of use of this library in course/edit.php and course/edit_form.php
A few notes : form definition is used for both printing of form and processing and should be the same for both or you may lose some submitted data which won't be let through. you should be using setType for every form element except select, radio or checkbox elements, these elements clean themselves.