a8b313d366fbf11e53b295500572a1d0b1268366
[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 <% if self.tabs then %>
27         <%+cbi/tabcontainer%>
28 <% else %>
29         <% self:render_children(section, scope or {}) %>
30 <% end %>
31
32 <% if self.error and self.error[section] then -%>
33         <div class="cbi-section-error">
34                 <ul><% for _, e in ipairs(self.error[section]) do %><li><%=pcdata(e):gsub("\n","<br />")%></li><% end %></ul>
35         </div>
36 <%- end %>
37
38 <% if self.optionals[section] and #self.optionals[section] > 0 or self.dynamic then %>
39         <div class="cbi-optionals">
40                 <% if self.dynamic then %>
41                         <input type="text" id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>" />
42                         <% if self.optionals[section] and #self.optionals[section] > 0 then %>
43                         <script type="text/javascript">
44                                 cbi_combobox_init('cbi.opt.<%=self.config%>.<%=section%>', {
45                                 <%-
46                                         for i, val in pairs(self.optionals[section]) do
47                                 -%>
48                                         <%-=string.format("%q", val.option) .. ":" .. string.format("%q", striptags(val.title))-%>
49                                         <%-if next(self.optionals[section], i) then-%>,<%-end-%>
50                                 <%-
51                                         end
52                                 -%>
53                                 }, '', '<%-:cbi_manual-%>');
54                         </script>
55                         <% end %>
56                 <% else %>
57                 <select id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>">
58                         <option><%:cbi_addopt%></option>
59                         <% for key, val in pairs(self.optionals[section]) do -%>
60                                 <option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>"><%=striptags(val.title)%></option>
61                         <%- end %>
62                 </select>
63                 <script type="text/javascript"><% for key, val in pairs(self.optionals[section]) do %>
64                         <% if #val.deps > 0 then %><% for j, d in ipairs(val.deps) do -%>
65                         cbi_d_add("cbi-<%=self.config.."-"..section.."-"..val.option..d.add%>", {
66                 <%-
67                         for k,v in pairs(d.deps) do
68                 -%>
69                         <%-=string.format('"cbid.%s.%s.%s"', self.config, section, k) .. ":" .. string.format("%q", v)-%>
70                         <%-if next(d.deps, k) then-%>,<%-end-%>
71                 <%-
72                         end
73                 -%>
74                         });
75                 <%- end %><% end %>
76                 <% end %></script>
77         <% end %>
78                 <input type="submit" class="cbi-button cbi-button-fieldadd" value="<%:add%>" />
79         </div>
80 <% end %>