kivitendo/templates/webpages/generic/multibox.html @ df193cf0
91ab1ef6 | Sven Schöling | [%- USE HTML %]
|
||
[%#-
|
||||
Multibox
|
||||
This template makes an input box for you,
|
||||
decides wether it should be a text field or a drop down box,
|
||||
generates the HTML code, and fixes everything just right.
|
||||
b364553b | Sven Schöling | call: PROCESS generic/multibox.html var = var, var2 = ....
|
||
91ab1ef6 | Sven Schöling | |||
options and variables:
|
||||
018e340a | Moritz Bunkus | name : name of the select/textfield
|
||
id : id of the select/textfield, optional, defaults to name
|
||||
default : entered/selected value. defaults to a dereference of name, since it is usually set to that for update mechanisms
|
||||
id_key : key that holds the id in each row.
|
||||
id_sub : name of a perl sub that calculates the id for each row. will be called with a hashref.
|
||||
label_key : key that holds the label in each row.
|
||||
label_sub : name of a perl sub that calculates the label for each row. will be called with a hashref.
|
||||
DATA : the actual data, expected to be arrayref of hashrefs, usually what's returned by the all_vc routines.
|
||||
show_empty : show an empty first line in select boxes. defaults to false
|
||||
style : additional style information
|
||||
onChange : java magic on change
|
||||
select : java function call for a selection popup or other magic
|
||||
allow_textbox : allow to display a textbox instead of a drop down box if there are more entries than 'limit' entries.
|
||||
limit : defines the limit of entries, after which a textbox is generated. defaults to vclimit, or, failing to find that, 200.
|
||||
198f860c | Sven Schöling | select_name : if a select is displayed, use a different name. ex.: department for textinput, but department_id for selects
|
||
4cc5904b | Sven Schöling | readonly : softly prevents modification
|
||
e03b46f1 | Moritz Bunkus | class : CSS class names (optional)
|
||
91ab1ef6 | Sven Schöling | -%]
|
||
198f860c | Sven Schöling | [%-
|
||
b364553b | Sven Schöling | Multibox__limit = limit != '' ? limit : vclimit != '' ? vclimit : 200
|
||
Multibox__show_text = allow_textbox and DATA.size and Multibox__limit < DATA.size ? 1 : 0
|
||||
335c0625 | Sven Schöling | Multibox__id = id != '' && id * 1 != id ? id : name
|
||
b364553b | Sven Schöling | Multibox__default = default != '' ? default : $name
|
||
Multibox__name = (select_name != '' and ! Multibox__show_text) ? select_name : name
|
||||
198f860c | Sven Schöling | -%]
|
||
b364553b | Sven Schöling | [%- IF Multibox__show_text %]
|
||
018e340a | Moritz Bunkus | <input type="text"
|
||
b364553b | Sven Schöling | [%- IF Multibox__name %] name="[% Multibox__name | html %]"[% END -%]
|
||
[%- IF Multibox__id %] id="[% Multibox__id | html %]"[% END -%]
|
||||
[%- IF Multibox__default %] value="[% Multibox__default | html %]"[% END -%]
|
||||
[%- IF style %] style="[% style | html %]"[% END -%]
|
||||
e03b46f1 | Moritz Bunkus | [%- IF class %] class="[% class | html %]"[% END -%]
|
||
b364553b | Sven Schöling | [%- IF readonly %] readonly[% END -%]
|
||
dc55d385 | Sven Schöling | [%- -%]>
|
||
[%- IF select -%]
|
||||
103dc24c | Sven Schöling | <input type="button" onclick="[% select %]" value="?">
|
||
dc55d385 | Sven Schöling | [%- END -%]
|
||
91ab1ef6 | Sven Schöling | [%- ELSE %]
|
||
018e340a | Moritz Bunkus | <select
|
||
b364553b | Sven Schöling | [%- IF Multibox__name %] name="[% Multibox__name | html %]"[% END -%]
|
||
[%- IF Multibox__id %] id="[% Multibox__id | html %]"[% END -%]
|
||||
[%- IF style %] style="[% style | html %]"[% END -%]
|
||||
e03b46f1 | Moritz Bunkus | [%- IF class %] class="[% class | html %]"[% END -%]
|
||
b364553b | Sven Schöling | [%- IF onChange %] onChange="[% onChange | html %]"[% END -%]
|
||
[%- IF readonly %] disabled[% END -%]
|
||||
dc55d385 | Sven Schöling | [%- -%]>
|
||
91ab1ef6 | Sven Schöling | [%- IF show_empty %]
|
||
<option value=""></option>
|
||||
[%- END %]
|
||||
[%- FOREACH row = DATA %]
|
||||
b364553b | Sven Schöling | [%-
|
||
Multibox__row_id = row.$id_key != '' ? row.$id_key : $id_sub(row)
|
||||
Multibox__row_label = row.$label_key != '' ? row.$label_key
|
||||
: $label_sub(row) != '' ? $label_sub(row)
|
||||
: Multibox__row_id
|
||||
Multibox__row_selected = Multibox__default == Multibox__row_id
|
||||
%]
|
||||
<option value="[% Multibox__row_id | html %]"[% IF Multibox__row_selected %] selected[% END %]>[% Multibox__row_label | html %]</option>
|
||||
91ab1ef6 | Sven Schöling | [%- END %]
|
||
</select>
|
||||
[%- END %]
|