-
Bug
-
Resolution: Fixed
-
Major
-
2.0.3, 2.1.1, 2.2
-
Any
-
MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
-
MOODLE_20_STABLE, MOODLE_21_STABLE
-
wip-mdl-27728
-
Easy
-
Within lib/formslib.php on form submit, the code is intended to step through the form elements and validate the value of each element.
Unfortunately, there are occasions when the element variable within the loop is undefined. This throws an exception. Since the form action has on exception return true, the form then gets submitted even though its values might not pass validation.
This can be avoided as follows:
Around line 1764 find
function validate_' . $this->_formName . '_' . $escapedElementName . '(element) {
|
Insert the following lines after it:
if( undefined == element ){
|
return false;
|
}
|
Then, around lines 1769 - 1774, find the range of lines beginning with
var frm = element.parentNode;
|
and ending with
return qf_errorHandler(element, _qfMsg);
|
Enclose this block in a condition like this:
if( undefined != element.name ){
|
var frm = element.parentNode;
|
while (frm && frm.nodeName.toUpperCase() != "FORM") {
|
frm = frm.parentNode;
|
}
|
' . join("\n", $jsArr) . '
|
|
return qf_errorHandler(element, _qfMsg);
|
}
|