1[%# This Source Code Form is subject to the terms of the Mozilla Public 2 # License, v. 2.0. If a copy of the MPL was not distributed with this 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 # 5 # This Source Code Form is "Incompatible With Secondary Licenses", as 6 # defined by the Mozilla Public License, v. 2.0. 7 #%] 8 9[%# INTERFACE: 10 # name: mandatory; field name 11 # id: optional; field id 12 # value: optional; default field value/selection 13 # classes: optional; an array of classes to be added 14 # onchange: optional; onchange attribute value 15 # disabled: optional; if true, the field is disabled 16 # accesskey: optional; accesskey attribute value 17 # add: optional; prepend menu option for value specified to start of select 18 # dontchange: optional; prepend menu option for "dontchange" to start of select 19 # multiple: optional; do multiselect box, value is size (height) of box 20 # title: optional; extra information to display as a tooltip 21 # products: optional; an array of custom product names 22 # isselect: optional; whether the product list should be displayed as a <select> 23 # or as just the plain text of its value. 24 # valueattribute: optional; the product attribute to be used for <option value="">, 25 # defaults to product name 26 #%] 27 28[% IF !isselect.defined %] 29 [% isselect = 1 %] 30[% END %] 31[% DEFAULT valueattribute = "name" %] 32[% IF isselect %] 33 <select name="[% name FILTER html %]" 34 [% IF id %] id="[% id FILTER html %]" [% END %] 35 [% IF classes %] class="[% classes.join(' ') FILTER html %]" [% END %] 36 [% IF onchange %] onchange="[% onchange FILTER html %]" [% END %] 37 [% IF disabled %] disabled="[% disabled FILTER html %]" [% END %] 38 [% IF accesskey %] accesskey="[% accesskey FILTER html %]" [% END %] 39 [% IF multiple %] multiple="multiple" size="[% multiple FILTER html %]" [% END %] 40 [% IF title %] title="[% title FILTER html %]" [% END %] 41 > 42 [% IF add %] 43 <option value="">[% add FILTER html %]</option> 44 [% END %] 45 [% IF dontchange %] 46 <option value="[% dontchange FILTER html %]">[% dontchange FILTER html %]</option> 47 [% END %] 48 49 [% IF Param('useclassification') %] 50 [% classifications = {} %] 51 [% IF products %] 52 [% FOREACH p = products %] 53 [% IF NOT classifications.${p.classification.name}.defined %] 54 [% classifications.${p.classification.name} = [] %] 55 [% END %] 56 [% classifications.${p.classification.name}.push(p) %] 57 [% END %] 58 [% ELSE %] 59 [% FOREACH c = user.get_selectable_classifications %] 60 [% classifications.${c.name} = [] %] 61 [% FOREACH p = user.get_selectable_products(c.id) %] 62 [% classifications.${c.name}.push(p) %] 63 [% END %] 64 [% END %] 65 [% END %] 66 67 [% FOREACH c = all_classifications %] 68 [% NEXT UNLESS classifications.${c}.size %] 69 <optgroup label="[% c FILTER html %]"> 70 [% FOREACH p = classifications.$c %] 71 <option value="[% p.$valueattribute FILTER html %]" 72 [% " selected" IF (cgi.param(name) == p.name) || (value.contains(p.name)) %]> 73 [% p.name FILTER html %] 74 </option> 75 [% END %] 76 </optgroup> 77 [% END %] 78 [% ELSE %] 79 [% IF NOT products.defined %] 80 [% products = user.get_selectable_products %] 81 [% END %] 82 [% FOREACH p = products %] 83 <option value="[% p.$valueattribute FILTER html %]" 84 [% " selected" IF (cgi.param(name) == p.name) || (value.contains(p.name)) %]> 85 [% p.name FILTER html %] 86 </option> 87 [% END %] 88 [% END %] 89 </select> 90[% ELSE %] 91 [% value.join(', ') FILTER html %] 92[% END %] 93