In PHP 8.2 and later, setting a value to an undeclared class property is
deprecated and emits a deprecation notice.
So we need to add missing class properties that still need to be declared.
Checks if a form element has attributes before
trying to get the default value. This fixes
an error when trying to get the default value
for a frozen group which does not have the
attributes array.
The legacy M.core.event.FORM_ERROR event has been replaced with a new
core_form/events::formError native DOM event.
The new event can be listened to at any point in the DOM using the
following syntax:
```
import {eventTypes} from 'core_form/events';
document.addEventListener(eventTypes.formError, handler);
```
A backward-compatabibility layer is included to ensure that any legacy
YUI event listener is still called with the same arguments.
This legacy bridges will be removed after Moodle 4.3.
The legacy M.core.event.FORM_SUBMIT_AJAX ecent has been replaced with a
new core_form/events::formSubmittedByJavascript native DOM event.
The new event can be listened to at any point in the DOM using the
following syntax:
```
import {eventTypes} from 'core_form/events';
document.addEventListener(eventTypes.formSubmittedByJavascript, handler);
```
A backward-compatabibility layer is included to ensure that any
legacy YUI event triggered on a form is still respected and the new
native event is also fired.
A similar handler is also included to ensure that any legacy YUI event
listener is still called with the same arguments.
These legacy bridges will be removed after Moodle 4.3.
When you download a file directly from a Moodle form submit button,
the submit button disables when you click it, but you remain on that
page so we need to re-enable the button.
This commit causes it to re-enable once the file download finishes,
setting a temporary cookie to indicate this to the JavaScript code.
It also adds a method to disable the system on a given form by
setting data-double-submit-protection="off".
When we deal with modal form submission we can not call optional_param inside the form class because
it does not have information from the AJAX form submission
Add an event that can be fired when an mform is about to be submitted via ajax.
This allows custom field types to perform an action when the form is submitted.
The atto text editor will reset any autosaves when the form is submitted.
The add/roles thing was only converted to bootstrap 2/4 markup and the yui left in place.
The modal for adding users to a course was unsavable so I rewrote it with an mform in a popup, still calling
the same (barely) modified ajax script.
The webservice for searching cohorts was taken from admin/tool/lp and moved into /cohort. I added a generic "cohort"
mform element at the same time.
The webservice for searching for users was taken from the original ajax script.
This patch introduces support for an optional method provided by the
form element classes to validate the submitted values implicitly -
without the need to have the rule explicitly added via the form
definition.
I am aware this should ideally be added to the HTML_QuickForm_element
parent class. But I wanted to avoid modification of that third party
library and keep the change in the moodleform layer only.