MDL-64151 form: autocomplete element remove last choice
This is the same situation as was in MDL-56864 but now in 'course', 'autocomplete' and 'select' elements - if the element allows multiple selection it is impossible to remove the last element
This commit is contained in:
+4
-2
@@ -166,8 +166,9 @@ class MoodleQuickForm_select extends HTML_QuickForm_select implements templatabl
|
||||
*/
|
||||
function exportValue(&$submitValues, $assoc = false)
|
||||
{
|
||||
$emptyvalue = $this->getMultiple() ? [] : '';
|
||||
if (empty($this->_options)) {
|
||||
return $this->_prepareValue(null, $assoc);
|
||||
return $this->_prepareValue($emptyvalue, $assoc);
|
||||
}
|
||||
|
||||
$value = $this->_findValue($submitValues);
|
||||
@@ -187,7 +188,7 @@ class MoodleQuickForm_select extends HTML_QuickForm_select implements templatabl
|
||||
}
|
||||
|
||||
if (empty($cleaned)) {
|
||||
return $this->_prepareValue(null, $assoc);
|
||||
return $this->_prepareValue($emptyvalue, $assoc);
|
||||
}
|
||||
if ($this->getMultiple()) {
|
||||
return $this->_prepareValue($cleaned, $assoc);
|
||||
@@ -223,6 +224,7 @@ class MoodleQuickForm_select extends HTML_QuickForm_select implements templatabl
|
||||
$options[] = $o;
|
||||
}
|
||||
$context['options'] = $options;
|
||||
$context['nameraw'] = $this->getName();
|
||||
|
||||
return $context;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user