241681f265ac728eaedf82dc4b181db1ad6866fd
[project/luci.git] / libs / cbi / luasrc / view / cbi / ucisection.htm
1 <%#
2 LuCI - Lua Configuration Interface
3 Copyright 2008 Steven Barth <steven@midlink.org>
4 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
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
16 <%-
17 if type(self.hidden) == "table" then
18 for k, v in pairs(self.hidden) do
19 -%>
20 <input type="hidden" id="cbid.<%=self.config%>.<%=section%>.<%=k%>" name="cbid.<%=self.config%>.<%=section%>.<%=k%>" value="<%=pcdata(v)%>" />
21 <%-
22 end
23 end
24 %>
25
26 <% self:render_children(section, scope or {}) %>
27
28 <% if self.error and self.error[section] then -%>
29 <div class="cbi-section-error">
30 <ul><% for _, e in ipairs(self.error[section]) do %><li><%=pcdata(e):gsub("\n","<br />")%></li><% end %></ul>
31 </div>
32 <%- end %>
33
34 <% if self.optionals[section] and #self.optionals[section] > 0 or self.dynamic then %>
35 <div class="cbi-optionals">
36 <% if self.dynamic then %>
37 <input type="text" id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>" />
38 <% if self.optionals[section] and #self.optionals[section] > 0 then %>
39 <script type="text/javascript">
40 cbi_combobox_init('cbi.opt.<%=self.config%>.<%=section%>', {
41 <%-
42 for i, val in pairs(self.optionals[section]) do
43 -%>
44 <%-=string.format("%q", val.option) .. ":" .. string.format("%q", striptags(val.title))-%>
45 <%-if next(self.optionals[section], i) then-%>,<%-end-%>
46 <%-
47 end
48 -%>
49 }, '', '<%-:cbi_manual-%>');
50 </script>
51 <% end %>
52 <% else %>
53 <select id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>">
54 <option><%:cbi_addopt%></option>
55 <% for key, val in pairs(self.optionals[section]) do -%>
56 <option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>"><%=striptags(val.title)%></option>
57 <%- end %>
58 </select>
59 <script type="text/javascript"><% for key, val in pairs(self.optionals[section]) do %>
60 <% if #val.deps > 0 then %><% for j, d in ipairs(val.deps) do -%>
61 cbi_d_add("cbi-<%=self.config.."-"..section.."-"..val.option..d.add%>", {
62 <%-
63 for k,v in pairs(d.deps) do
64 -%>
65 <%-=string.format('"cbid.%s.%s.%s"', self.config, section, k) .. ":" .. string.format("%q", v)-%>
66 <%-if next(d.deps, k) then-%>,<%-end-%>
67 <%-
68 end
69 -%>
70 });
71 <%- end %><% end %>
72 <% end %></script>
73 <% end %>
74 <input type="submit" class="cbi-button cbi-button-fieldadd" value="<%:add%>" />
75 </div>
76 <% end %>