MDL-57680 form autocomplete: let singleselects be cleared.

This was already working after ajax had refreshed the choices, it was just
broken on first page load.
This commit is contained in:
Tim Hunt
2020-04-26 13:23:42 +01:00
parent 9df4a4de18
commit 588b86fd49
4 changed files with 9 additions and 3 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+6
View File
@@ -1026,6 +1026,12 @@ function($, log, str, templates, notification, LoadingIcon) {
uniqueId++;
options.multiple = originalSelect.attr('multiple');
if (!options.multiple) {
// If this is a single select then there is no way to de-select the current value -
// unless we add a bogus blank option to be selected when nothing else is.
// This matches similar code in updateAjax above.
originalSelect.prepend('<option>');
}
if (typeof closeSuggestionsOnSelect !== "undefined") {
options.closeSuggestionsOnSelect = closeSuggestionsOnSelect;
+1 -1
View File
@@ -124,7 +124,7 @@ class MoodleQuickForm_course extends MoodleQuickForm_autocomplete {
$coursestofetch = array();
foreach ($values as $onevalue) {
if ((!$this->optionExists($onevalue)) &&
if ($onevalue && !$this->optionExists($onevalue) &&
($onevalue !== '_qf__force_multiselect_submission')) {
array_push($coursestofetch, $onevalue);
}