Skip to main content

Form elements

Custom form elements for Moodle

In development

How to use moodle forms

Forms are constructed using lib/formslib.php. Using the addElement methods in php a set of different form element types can be added to a form. For more info visit the Moodledocs page for forms

    $mform->addElement('button', 'intro', get_string("buttonlabel"));

Form elements are styled using Moodle templates which are rendered through PHP. Themes can override these templates.

Form elements are styled using the .form-control class, see the Bootstrap docs for more info.

Example form elements

The example form below is showing an iframe with an actual Moodle form. Use the toggle options to display the different states for the form.