-
Type:
Bug
-
Status: Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 3.1
-
Fix Version/s: 3.1
-
Component/s: Forms Library
-
Testing Instructions:
-
Affected Branches:MOODLE_31_STABLE
-
Fixed Branches:MOODLE_31_STABLE
-
Pull from Repository:
-
Pull Master Branch:
MDL-53889-master -
Pull Master Diff URL:
If you create a form with an autocomplete field that allows multiple selection, and call set_data with a list of values, "No selection" is displayed instead of the list of options.
This only happens when the fields are loaded in via AJAX.
Example code (assumes you have created two courses):
$mform->addElement('course', 'test', 'I am a test', array(
|
'multiple' => true,
|
));
|
$mform->set_data(array('test' => [2,3]));
|
Looking through form-autocomplete.js I got to:
originalSelect.children('option').each(function(index, ele) {
|
if ($(ele).prop('selected')) {
|
items.push( { label: $(ele).html(), value: $(ele).attr('value') } );
|
}
|
});
|
"$(ele).prop('selected')" is returning false for all elements of a multi-select, when every element is actually a valid item for the template.