Merge branch 'MDL-60675-33' of git://github.com/mihailges/moodle into MOODLE_33_STABLE
This commit is contained in:
@@ -1105,6 +1105,7 @@ class single_select implements renderable, templatable {
|
||||
if (is_string($this->nothing) && $this->nothing !== '') {
|
||||
$nothing = ['' => $this->nothing];
|
||||
$hasnothing = true;
|
||||
$nothingkey = '';
|
||||
} else if (is_array($this->nothing)) {
|
||||
$nothingvalue = reset($this->nothing);
|
||||
if ($nothingvalue === 'choose' || $nothingvalue === 'choosedots') {
|
||||
@@ -1113,6 +1114,7 @@ class single_select implements renderable, templatable {
|
||||
$nothing = $this->nothing;
|
||||
}
|
||||
$hasnothing = true;
|
||||
$nothingkey = key($this->nothing);
|
||||
}
|
||||
if ($hasnothing) {
|
||||
$options = $nothing + $this->options;
|
||||
@@ -1125,11 +1127,17 @@ class single_select implements renderable, templatable {
|
||||
foreach ($options[$value] as $optgroupname => $optgroupvalues) {
|
||||
$sublist = [];
|
||||
foreach ($optgroupvalues as $optvalue => $optname) {
|
||||
$sublist[] = [
|
||||
$option = [
|
||||
'value' => $optvalue,
|
||||
'name' => $optname,
|
||||
'selected' => strval($this->selected) === strval($optvalue),
|
||||
];
|
||||
|
||||
if ($hasnothing && $nothingkey == $optvalue) {
|
||||
$option['ignore'] = 'data-ignore';
|
||||
}
|
||||
|
||||
$sublist[] = $option;
|
||||
}
|
||||
$data->options[] = [
|
||||
'name' => $optgroupname,
|
||||
@@ -1138,12 +1146,18 @@ class single_select implements renderable, templatable {
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$data->options[] = [
|
||||
$option = [
|
||||
'value' => $value,
|
||||
'name' => $options[$value],
|
||||
'selected' => strval($this->selected) === strval($value),
|
||||
'optgroup' => false
|
||||
];
|
||||
|
||||
if ($hasnothing && $nothingkey == $value) {
|
||||
$option['ignore'] = 'data-ignore';
|
||||
}
|
||||
|
||||
$data->options[] = $option;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@
|
||||
</optgroup>
|
||||
{{/optgroup}}
|
||||
{{^optgroup}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{{name}}}</option>
|
||||
<option {{ignore}} value="{{value}}" {{#selected}}selected{{/selected}}>{{{name}}}</option>
|
||||
{{/optgroup}}
|
||||
{{/options}}
|
||||
</select>
|
||||
@@ -117,7 +117,10 @@
|
||||
{{#js}}
|
||||
require(['jquery'], function($) {
|
||||
$('#{{id}}').change(function() {
|
||||
$('#{{formid}}').submit();
|
||||
var ignore = $(this).find(':selected').attr('data-ignore');
|
||||
if (typeof ignore === typeof undefined) {
|
||||
$('#{{formid}}').submit();
|
||||
}
|
||||
});
|
||||
});
|
||||
{{/js}}
|
||||
|
||||
Reference in New Issue
Block a user