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.
This commit is contained in:
Amaia Anabitarte
2024-03-27 16:19:45 +01:00
committed by Amaia Anabitarte
parent c895def59b
commit 0c2c00cdb8
2 changed files with 4 additions and 2 deletions
+3 -2
View File
@@ -1571,15 +1571,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;