MDL-74054 qbank_columnsortorder: Move away from ModalFactory
[moodle.git] / lib / form / templates / element-select.mustache
blob364fc2eabe03ba662e0b8a088212b17c2fe824ae
1 {{!
2     This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
17 {{!
18     @template core_form/element-select
20     Simple select form element template.
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     ]
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     }
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             {{{element.attributes}}} >
111             {{#element.options}}
112             <option value="{{value}}" {{#selected}}selected{{/selected}} {{#disabled}}disabled{{/disabled}}
113                 {{{optionattributes}}}>{{{text}}}</option>
114             {{/element.options}}
115         </select>
116         {{/element.frozen}}
117         {{#element.frozen}}
118             {{#element.options}}
119                 {{#selected}}
120                     {{{text}}}
121                     {{^element.hardfrozen}}
122                         <input type="hidden" name="{{element.name}}" value="{{value}}" id="{{element.id}}">
123                     {{/element.hardfrozen}}
124                 {{/selected}}
125             {{/element.options}}
126         {{/element.frozen}}
127     {{/element}}
128 {{/ core_form/element-template }}