MDL-87438 core: Fix multiselect saving with empty choices

This commit is contained in:
Muhammad Arnaldo
2026-03-05 14:23:19 +07:00
parent abfa0b8d72
commit 7299e4dcb6
+6 -3
View File
@@ -3682,12 +3682,15 @@ class admin_setting_configmultiselect extends admin_setting_configselect {
if (!is_array($data)) {
return ''; //ignore it
}
if (!$this->load_choices() or empty($this->choices)) {
return '';
}
unset($data['xxxxx']);
// Only reject when the caller actually supplied a value
// and there is no valid choices to validate against.
if (!empty($data) && (!$this->load_choices() || empty($this->choices))) {
return '';
}
$save = array();
foreach ($data as $value) {
if (!array_key_exists($value, $this->choices)) {