Button nicht benutzen. Wird von Konqueror seltsam gerendert.
[kivitendo-erp.git] / templates / webpages / generic / multibox.html
1 [%- USE HTML %]
2 [%#-
3      Multibox
4
5   This template makes an input box for you,
6   decides wether it should be a text field or a drop down box,
7   generates the HTML code, and fixes everything just right.
8
9   call:  INCLUDE generic/multibox.html var = var, var2 = .... 
10
11   options and variables:
12     name       : name of the select/textfield
13     id         : id of the select/textfield, optional, defaults to name
14     default    : entered/selected value. defaults to a dereference of name, since it is usually set to that for update mechanisms
15     id_key     : key that holds the id in each row.
16     id_sub     : name of a perl sub that calculates the id for each row. will be called with a hashref.
17     label_key  : key that holds the label in each row.
18     label_sub  : name of a perl sub that calculates the label for each row. will be called with a hashref.
19     DATA       : the actual data, expected to be arrayref of hashrefs, usually what's returned by the all_vc routines.
20     limit      : defines the limit of entries, after which a textbox is generated. defaults to vclimit, or, failing to find that, 50.
21     show_empty : show an empty first line in select boxes. defaults to false
22     style      : additional style information
23     onChange   : java magic on change
24     select     : java function call for a selection popup or other magic
25 -%]
26 [%- DEFAULT 
27   limit      = limit != ''   ? limit   : 50
28   id         = id    != ''   ? id      : name
29   default    = default != '' ? default : $name
30 -%]
31 [%- FOREACH row = DATA %]
32   [%-
33        row.id       = row.$id_key     != ''  ? row.$id_key    : $id_sub(row)
34        row.label    = row.$label_key  != ''  ? row.$label_key 
35                     : $label_sub(row) != ''  ? $label_sub(row) 
36                     :                          row.id
37        row.selected = default == row.id
38   -%]
39 [%- END -%]
40 [%- IF DATA.size and limit < DATA.size %]
41 <input type="text" 
42  [%- IF name     %] name="[%     HTML.escape(name)     %]"[% END %]
43  [%- IF id       %] id="[%       HTML.escape(id)       %]"[% END %]
44  [%- IF default  %] value="[%    HTML.escape(default)  %]"[% END %]
45  [%- IF style    %] style="[%    HTML.escape(style)    %]"[% END %]
46 >
47 [%- IF select %]
48   <input type="button" onclick="[% select %]" value="?">
49 [% END %]
50 [%- ELSE %]
51 <select 
52  [%- IF name     %] name="[%     HTML.escape(name)     %]"[% END %]
53  [%- IF id       %] id="[%       HTML.escape(id)       %]"[% END %]
54  [%- IF style    %] style="[%    HTML.escape(style)    %]"[% END %]
55  [%- IF onChange %] onChange="[% HTML.escape(onChange) %]"[% END %]
56 >
57   [%- IF show_empty %]
58   <option value=""></option>
59   [%- END %]
60   [%- FOREACH row = DATA %]
61   <option value="[% row.id %]"[% IF row.selected %] selected[% END %]>[% HTML.escape(row.label) %]</option>
62   [%- END %]
63 </select>
64 [%- END %]