From 972e6ffe4712d67a6b109e6da084fc6ed91872dc Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Wed, 24 Feb 2021 09:05:36 +0800 Subject: [PATCH] MDL-70987 core_form: Use correct id for elementid during validation The id of the formid was being passed instead of the elementid. --- lib/formslib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/formslib.php b/lib/formslib.php index 8701bbd2e8e..3251ad1bdc7 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -2579,7 +2579,7 @@ require(["core/event", "jquery"], function(Event, $) { } } // This handles both randomised (MDL-65217) and non-randomised IDs. - $errorid = preg_replace('/^id_/', 'id_error_', $this->_attributes['id']); + $errorid = preg_replace('/^id_/', 'id_error_', $elem->_attributes['id']); $validateJS .= ' ret = validate_' . $this->_formName . '_' . $escapedElementName.'(frm.elements[\''.$elementName.'\'], \''.$escapedElementName.'\') && ret; if (!ret && !first_focus) {