| 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_form/element-select
|
|
|
19 |
|
|
|
20 |
Simple select form element template.
|
|
|
21 |
|
|
|
22 |
Context variables required for this template:
|
|
|
23 |
* id - Element id,
|
|
|
24 |
* nameraw - Raw Element name without '[]'
|
|
|
25 |
* name - Element name,
|
|
|
26 |
* label - Element label,
|
|
|
27 |
* multiple - multi select?,
|
|
|
28 |
* checked - checked?,
|
|
|
29 |
* error - Is there an error associated with this element?,
|
|
|
30 |
* size - Element size,
|
|
|
31 |
* value - Element value,
|
|
|
32 |
* helpbutton - Helpbutton,
|
|
|
33 |
* hiddenlabel - Element hidden flag,
|
|
|
34 |
* frozen - Element frozen flag,
|
|
|
35 |
* hardfrozen - Element hard fronzen flag,
|
|
|
36 |
* extraclasses - Extra classes assocaited,
|
|
|
37 |
* type - Element type,
|
|
|
38 |
* attributes - Element attributes,
|
|
|
39 |
* options - [
|
|
|
40 |
{
|
|
|
41 |
text - Option text,
|
|
|
42 |
value - Option value,
|
|
|
43 |
selected - Selected?,
|
|
|
44 |
disabled - Disabled?,
|
|
|
45 |
optionattributes - Option attributes
|
|
|
46 |
}
|
|
|
47 |
]
|
|
|
48 |
|
|
|
49 |
Example context (json):
|
|
|
50 |
{
|
|
|
51 |
"element": {
|
|
|
52 |
"id": "id_maildisplay",
|
|
|
53 |
"nameraw": "maildisplay",
|
|
|
54 |
"name": "maildisplay",
|
|
|
55 |
"label": null,
|
|
|
56 |
"multiple": null,
|
|
|
57 |
"checked": null,
|
|
|
58 |
"error": null,
|
|
|
59 |
"size": null,
|
|
|
60 |
"value": null,
|
|
|
61 |
"helpbutton": "",
|
|
|
62 |
"hiddenlabel": false,
|
|
|
63 |
"frozen": false,
|
|
|
64 |
"hardfrozen": false,
|
|
|
65 |
"extraclasses": null,
|
|
|
66 |
"type": "select",
|
|
|
67 |
"attributes": "",
|
|
|
68 |
"options": [
|
|
|
69 |
{
|
|
|
70 |
"text": "Hidden",
|
|
|
71 |
"value": 0,
|
|
|
72 |
"selected": false,
|
|
|
73 |
"disabled": false,
|
|
|
74 |
"optionattributes": ""
|
|
|
75 |
},
|
|
|
76 |
{
|
|
|
77 |
"text": "Visible to everyone",
|
|
|
78 |
"value": 1,
|
|
|
79 |
"selected": true,
|
|
|
80 |
"disabled": false,
|
|
|
81 |
"optionattributes": ""
|
|
|
82 |
},
|
|
|
83 |
{
|
|
|
84 |
"text": "Allow only other course members to see my email address",
|
|
|
85 |
"value": 2,
|
|
|
86 |
"selected": false,
|
|
|
87 |
"disabled": false,
|
|
|
88 |
"optionattributes": ""
|
|
|
89 |
}
|
|
|
90 |
]
|
|
|
91 |
}
|
|
|
92 |
}
|
|
|
93 |
}}
|
|
|
94 |
{{< core_form/element-template }}
|
|
|
95 |
{{$element}}
|
|
|
96 |
{{^element.frozen}}
|
|
|
97 |
{{#element.multiple}}
|
|
|
98 |
<input type="hidden" name="{{element.nameraw}}" value="_qf__force_multiselect_submission">
|
|
|
99 |
{{/element.multiple}}
|
|
|
100 |
<select class="{{^element.multiple}}custom-select{{/element.multiple}}
|
|
|
101 |
{{#element.multiple}}form-control{{/element.multiple}}
|
|
|
102 |
{{#error}}is-invalid{{/error}}"
|
|
|
103 |
name="{{element.name}}"
|
|
|
104 |
id="{{element.id}}"
|
|
|
105 |
{{#element.multiple}}multiple{{/element.multiple}}
|
|
|
106 |
{{#element.size}}size="{{element.size}}"{{/element.size}}
|
|
|
107 |
{{#error}}
|
|
|
108 |
autofocus aria-describedby="{{element.iderror}}"
|
|
|
109 |
{{/error}}
|
|
|
110 |
{{#required}}
|
|
|
111 |
aria-required="true"
|
|
|
112 |
{{/required}}
|
|
|
113 |
{{{element.attributes}}} >
|
|
|
114 |
{{#element.options}}
|
|
|
115 |
<option value="{{value}}" {{#selected}}selected{{/selected}} {{#disabled}}disabled{{/disabled}}
|
|
|
116 |
{{{optionattributes}}}>{{{text}}}</option>
|
|
|
117 |
{{/element.options}}
|
|
|
118 |
</select>
|
|
|
119 |
{{/element.frozen}}
|
|
|
120 |
{{#element.frozen}}
|
|
|
121 |
{{#element.options}}
|
|
|
122 |
{{#selected}}
|
|
|
123 |
{{{text}}}
|
|
|
124 |
{{^element.hardfrozen}}
|
|
|
125 |
<input type="hidden" name="{{element.name}}" value="{{value}}" id="{{element.id}}">
|
|
|
126 |
{{/element.hardfrozen}}
|
|
|
127 |
{{/selected}}
|
|
|
128 |
{{/element.options}}
|
|
|
129 |
{{/element.frozen}}
|
|
|
130 |
{{/element}}
|
|
|
131 |
{{/ core_form/element-template }}
|