diff --git a/lib/form/selectgroups.php b/lib/form/selectgroups.php index ed64e716504..99ef7e011af 100644 --- a/lib/form/selectgroups.php +++ b/lib/form/selectgroups.php @@ -376,6 +376,9 @@ class MoodleQuickForm_selectgroups extends HTML_QuickForm_element implements tem if (is_array($this->_values)) { foreach ($this->_values as $key => $val) { foreach ($this->_optGroups as $optGroup) { + if (empty($optGroup['options'])) { + continue; + } for ($i = 0, $optCount = count($optGroup['options']); $i < $optCount; $i++) { if ((string)$val == (string)$optGroup['options'][$i]['attr']['value']) { $value[$key] = $optGroup['options'][$i]['text'];