In the previous section, we skimmed over creating a form and using it without going into any specific details. Now, let's look at what we actually do to define and use a form.
As described in the previous section, we begin by creating a class that extends moodleform
. Then, we add a definition
function so that we can create all of our form elements. Next, we will describe the functions that we can use to create our form.
A form element is a standard HTML form structure, such as a drop-down menu, text entry box, or radio button, which can be used to extract information interactively from a web user. A form element object is a code structure that contains all of the data and code to display, validate, and extract from a form element.
The two main functions to add form elements to your form are addElement
and createElement
. These are essentially the same function, except that createElement
returns the created form element object without...