libs/cbi:
[project/luci.git] / libs / cbi / luasrc / view / cbi / dynlist.htm
1 <%#
2 LuCI - Lua Configuration Interface
3 Copyright 2008 Steven Barth <steven@midlink.org>
4 Copyright 2008-2010 Jo-Philipp Wich <xm@subsignal.org>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13
14 -%>
15 <%+cbi/valueheader%>
16 <%
17         local vals = self:cfgvalue(section) or {}
18         for i=1, #vals + 1 do
19                 local val = vals[i]
20 %>
21         <input class="cbi-input-text" value="<%=pcdata(val)%>" onchange="cbi_d_update(this.id)" type="text"<%= attr("id", cbid .. "." .. i) .. attr("name", cbid) .. ifattr(self.size, "size")%> />
22         <% if i <= #vals then %>
23                 <input class="cbi-input-image" type="image" value="<%:Delete%>" name="cbi.rle.<%=section .. "." .. self.option .. "." .. i%>" alt="<%:Delete%>" title="<%:Delete%>" src="<%=resource%>/cbi/remove.gif" />
24         <% else %>
25                 <input class="cbi-input-image" type="image" value="<%:Add%>" name="cbi.ale.<%=section .. "." .. self.option%>" alt="<%:Add%>" title="<%:Add%>" src="<%=resource%>/cbi/add.gif" />
26         <% end %>
27         <% if #self.keylist > 0 then -%>
28                 <script type="text/javascript">
29                         cbi_combobox_init('<%=cbid .. "." .. i%>', {
30                         <%-
31                                 for i, k in ipairs(self.keylist) do
32                         -%>
33                                 <%-=string.format("%q", k) .. ":" .. string.format("%q", self.vallist[i])-%>
34                                 <%-if i<#self.keylist then-%>,<%-end-%>
35                         <%-
36                                 end
37                         -%>
38                         }, '<%- if not self.rmempty and not self.optional then -%>
39                                 <%-:cbi_select-%>
40                         <%- end -%>', '<%: -- custom -- %>');
41                 </script>
42         <% end -%>
43 <% if i <= #vals then %><br />
44 <% end end %>
45 <% if self.datatype then -%>
46         <script type="text/javascript">
47                 <% for i=1, #vals + 1 do -%>
48                 cbi_validate_field('<%=cbid%>.<%=i%>', <%=tostring(self.optional == true or i > #vals)%>, '<%=self.datatype%>');
49                 <%- end %>
50         </script>
51 <% end -%>
52 <%+cbi/valuefooter%>