1 |
efrain |
1 |
{{!
|
|
|
2 |
This file is part of Moodle - http://moodle.org/
|
|
|
3 |
|
|
|
4 |
Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
it under the terms of the GNU General Public License as published by
|
|
|
6 |
the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
(at your option) any later version.
|
|
|
8 |
|
|
|
9 |
Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
GNU General Public License for more details.
|
|
|
13 |
|
|
|
14 |
You should have received a copy of the GNU General Public License
|
|
|
15 |
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
}}
|
|
|
17 |
{{!
|
|
|
18 |
@template core_admin\local\settings\autocomplete
|
|
|
19 |
|
|
|
20 |
Admin setting auto complete.
|
|
|
21 |
|
|
|
22 |
Context variables required for this template:
|
|
|
23 |
* name - element name
|
|
|
24 |
* id - element id
|
|
|
25 |
* options - choices
|
|
|
26 |
* multiple - is multiple choices?
|
|
|
27 |
* manageurl - url to manage choices
|
|
|
28 |
* managetext - string to display manage url
|
|
|
29 |
* tags - Should we allow typing new entries to the field?
|
|
|
30 |
* ajax - Name of an AMD module to send/process ajax requests
|
|
|
31 |
* placeholder - Placeholder text for an empty list
|
|
|
32 |
* casesensitive - Whether the search has to be case-sensitive
|
|
|
33 |
* showsuggestions - Show suggestions by default - but this can be turned off
|
|
|
34 |
* noselectionstring - String that is shown when there are no selections
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
Example context (json):
|
|
|
38 |
{
|
|
|
39 |
"name": "name0",
|
|
|
40 |
"id": "id0",
|
|
|
41 |
"options": [{
|
|
|
42 |
"value": "1",
|
|
|
43 |
"text": "option 1",
|
|
|
44 |
"selected": true,
|
|
|
45 |
"disabled": false
|
|
|
46 |
}],
|
|
|
47 |
"multiple": true,
|
|
|
48 |
"manageurl": "",
|
|
|
49 |
"managetext": "",
|
|
|
50 |
"tags": false,
|
|
|
51 |
"ajax": "",
|
|
|
52 |
"placeholder": "",
|
|
|
53 |
"casesensitive": false,
|
|
|
54 |
"showsuggestions": true,
|
|
|
55 |
"noselectionstring": ""
|
|
|
56 |
}
|
|
|
57 |
}}
|
|
|
58 |
{{!
|
|
|
59 |
Setting autocomplete.
|
|
|
60 |
}}
|
|
|
61 |
|
|
|
62 |
<div class="form-select defaultsnext">
|
|
|
63 |
<input type="hidden" name="{{name}}[xxxxx]" value="_qf__force_multiselect_submission">
|
|
|
64 |
<select class="custom-select" name="{{name}}[]"
|
|
|
65 |
id="{{id}}"
|
|
|
66 |
{{#multiple}}multiple{{/multiple}}>
|
|
|
67 |
{{#options}}
|
|
|
68 |
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{{text}}}</option>
|
|
|
69 |
{{/options}}
|
|
|
70 |
</select>
|
|
|
71 |
{{#manageurl}}
|
|
|
72 |
<a href="{{manageurl}}">{{managetext}}</a>
|
|
|
73 |
{{/manageurl}}
|
|
|
74 |
</div>
|
|
|
75 |
<br/>
|
|
|
76 |
|
|
|
77 |
{{#js}}
|
|
|
78 |
require(['core/form-autocomplete'], function(module) {
|
|
|
79 |
module.enhance({{#quote}}#{{id}}{{/quote}},
|
|
|
80 |
{{tags}},
|
|
|
81 |
{{#quote}}{{ajax}}{{/quote}},
|
|
|
82 |
{{#quote}}{{placeholder}}{{/quote}},
|
|
|
83 |
{{casesensitive}},
|
|
|
84 |
{{showsuggestions}},
|
|
|
85 |
{{#quote}}{{noselectionstring}}{{/quote}});
|
|
|
86 |
});
|
|
|
87 |
{{/js}}
|