From b459df584ca62bfbf18c73d9082de8257abec284 Mon Sep 17 00:00:00 2001 From: Amaia Anabitarte Date: Thu, 29 Feb 2024 16:30:24 +0100 Subject: [PATCH] MDL-80818 QuickForm: Freeze all elements with the same name There are some radio buttons in activity Completion Conditions settings that must be frozen altogether, because all of them have the same name. --- lib/pear/HTML/QuickForm.php | 5 +++-- lib/pear/readme_moodle.txt | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/pear/HTML/QuickForm.php b/lib/pear/HTML/QuickForm.php index 6cec481f024..7d55dcdbd50 100644 --- a/lib/pear/HTML/QuickForm.php +++ b/lib/pear/HTML/QuickForm.php @@ -1570,15 +1570,16 @@ class HTML_QuickForm extends HTML_Common { $elementList = array_flip($elementList); } + $frozen = []; foreach (array_keys($this->_elements) as $key) { $name = $this->_elements[$key]->getName(); if ($this->_freezeAll || isset($elementList[$name])) { $this->_elements[$key]->freeze(); - unset($elementList[$name]); + $frozen[$name] = true; } } - if (!empty($elementList)) { + if (count($elementList) != count($frozen)) { return self::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Nonexistant element(s): '" . implode("', '", array_keys($elementList)) . "' in HTML_QuickForm::freeze()", 'HTML_QuickForm_Error', true); } return true; diff --git a/lib/pear/readme_moodle.txt b/lib/pear/readme_moodle.txt index b585c1357e5..caa8a112ba6 100644 --- a/lib/pear/readme_moodle.txt +++ b/lib/pear/readme_moodle.txt @@ -38,6 +38,7 @@ MDL-77164 - PHPdocs corrections MDL-78145 - PHP 8.2 compliance. Added a missing class property that still need to be declared to avoid dynamic properties deprecated error warning. And also remove the $_elementIdx because it is not needed in Moodle code. +MDL-80818 - Freezing all elements with the same name (e.g. radio buttons) Pear ====