MDL-56282 enrol_meta: Fix error when editing existing instances

We had a few problems here.

1/ The auto complete element was displaying the picker though the
   field was frozen.
2/ Checking for existing enrolment including the courses chosen was
   not checking if the courses found were in the instance we edit.
3/ Upon creation we support multiple courses but when editing we
   should not expect more than the course in the instance being edited.
This commit is contained in:
Frédéric Massart 2016-10-06 11:48:22 +02:00 committed by Damyon Wiese
parent 09a05b798b
commit 77bec234e0
2 changed files with 18 additions and 6 deletions

View file

@ -121,8 +121,11 @@ class MoodleQuickForm_autocomplete extends MoodleQuickForm_select {
// Enhance the select with javascript.
$this->_generateId();
$id = $this->getAttribute('id');
$PAGE->requires->js_call_amd('core/form-autocomplete', 'enhance', $params = array('#' . $id, $this->tags, $this->ajax,
$this->placeholder, $this->casesensitive, $this->showsuggestions, $this->noselectionstring));
if (!$this->isFrozen()) {
$PAGE->requires->js_call_amd('core/form-autocomplete', 'enhance', $params = array('#' . $id, $this->tags, $this->ajax,
$this->placeholder, $this->casesensitive, $this->showsuggestions, $this->noselectionstring));
}
return parent::toHTML();
}