Multibox: Keine Variablen in den rows speichern
[kivitendo-erp.git] / templates / webpages / generic / multibox.html
index b78f1bc..72d8957 100644 (file)
     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.
+    select_name   : if a select is displayed, use a different name. ex.: department for textinput, but department_id for selects
+    readonly      : softly prevents modification
 -%]
 [%- DEFAULT
   limit      = limit   != '' ? limit   : vclimit != '' ? vclimit : 200
+  show_text  = allow_textbox and DATA.size and limit < DATA.size ? 1 : 0
   id         = id      != '' ? id      : name
   default    = default != '' ? default : $name
 -%]
-[%- FOREACH row = DATA %]
-  [%-
-       row.id       = row.$id_key     != ''  ? row.$id_key    : $id_sub(row)
-       row.label    = row.$label_key  != ''  ? row.$label_key
-                    : $label_sub(row) != ''  ? $label_sub(row)
-                    :                          row.id
-       row.selected = default == row.id
-  -%]
-[%- END -%]
-[%- IF allow_textbox and DATA.size and limit < DATA.size %]
+[%-
+  name       = (select_name != '' and ! show_text) ? select_name : name
+-%]
+[%- IF show_text %]
 <input type="text"
  [%- IF name     %] name="[%     HTML.escape(name)     %]"[% END -%]
  [%- IF id       %] id="[%       HTML.escape(id)       %]"[% END -%]
  [%- IF default  %] value="[%    HTML.escape(default)  %]"[% END -%]
  [%- IF style    %] style="[%    HTML.escape(style)    %]"[% END -%]
+ [%- IF readonly %] readonly[% END -%]
 [%- -%]>
 [%- IF select -%]
   <input type="button" onclick="[% select %]" value="?">
  [%- IF id       %] id="[%       HTML.escape(id)       %]"[% END -%]
  [%- IF style    %] style="[%    HTML.escape(style)    %]"[% END -%]
  [%- IF onChange %] onChange="[% HTML.escape(onChange) %]"[% END -%]
+ [%- IF readonly %] disabled[% END -%]
 [%- -%]>
   [%- IF show_empty %]
   <option value=""></option>
   [%- END %]
   [%- FOREACH row = DATA %]
-  <option value="[% row.id %]"[% IF row.selected %] selected[% END %]>[% HTML.escape(row.label) %]</option>
+  <option value="[% row.$id_key != '' ? row.$id_key : $id_sub(row) | html %]"[% IF default == (row.$id_key != '' ? row.$id_key : $id_sub(row)) %] selected[% END %]>[%
+                      row.$label_key  != ''  ? row.$label_key
+                    : $label_sub(row) != ''  ? $label_sub(row)
+                    : row.$id_key     != ''  ? row.$id_key
+                    :                          $id_sub(row) | html %]</option>
   [%- END %]
 </select>
 [%- END %]