What we’ll cover in this section is the model side of things.Essentially: what happens when you call the save() method of your model.Custom validation is declared by passing a validation function.
If you wish to use the form within a block then you should consider using the render method, as demonstrated below: Note that the render method does the same as the display method, except returning the HTML rather than outputting it to the browser, as with above make sure you've included the file which contains the class for your Moodle form.
You will normally use this helper function which is a method of moodleform to add all the 'action' buttons to the end of your form.
Setting the attribute for an input will add the icon after its label: BTW, you can add any additional validation rule to the required fields.
For example, for the 'E-mail'/'Confirm e-mail' fields (in the image above) you can set the You can also handle HTML input-related events, such as onblur (fires when the element which is in focus, loses that focus).
A boolean parameter allow you to specify whether to include a cancel button and specify the label for your submit button (pass the result of get_string).
Default for the submit button label is get_string('savechanges').
Note the $this not $mform To set the default value for an element.
For any element or groups of element in a form you can conditionally disable the group or individual element depending on conditions. Like text field is required element and is of type email. Adds pop-up help button to a form element PARAM_* types are used to specify how a submitted variable should be cleaned.
Marking an input component as immediate does NOT affect the model update; any new data is still pushed into the model at the Update Model phase (ie after any immediate command components have executed). Value Change Listener could be used to update the model directly.
Using immediate causes the component Action Listener or action-method to be executed at the end of the apply-request-values phase, ie before any non-immediate value validation and before any backing bean updates (update-model phase).
By default, any Moodle form will pop-up an "Are you sure?