build: introduce luci-base
[project/luci.git] / modules / base / luasrc / luasrc / view / cbi / ucisection.htm
1 <%-
2 if type(self.hidden) == "table" then
3 for k, v in pairs(self.hidden) do
4 -%>
5 <input type="hidden" id="<%=k%>" name="<%=k%>" value="<%=pcdata(v)%>" />
6 <%-
7 end
8 end
9 %>
10
11 <% if self.tabs then %>
12 <%+cbi/tabcontainer%>
13 <% else %>
14 <% self:render_children(section, scope or {}) %>
15 <% end %>
16
17 <% if self.error and self.error[section] then -%>
18 <div class="cbi-section-error">
19 <ul><% for _, e in ipairs(self.error[section]) do -%>
20 <li>
21 <%- if e == "invalid" then -%>
22 <%:One or more fields contain invalid values!%>
23 <%- elseif e == "missing" then -%>
24 <%:One or more required fields have no value!%>
25 <%- else -%>
26 <%=pcdata(e)%>
27 <%- end -%>
28 </li>
29 <%- end %></ul>
30 </div>
31 <%- end %>
32
33 <% if self.optionals[section] and #self.optionals[section] > 0 or self.dynamic then %>
34 <div class="cbi-optionals">
35 <% if self.dynamic then %>
36 <input type="text" id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>" />
37 <% if self.optionals[section] and #self.optionals[section] > 0 then %>
38 <script type="text/javascript">
39 cbi_combobox_init('cbi.opt.<%=self.config%>.<%=section%>', {
40 <%-
41 for i, val in pairs(self.optionals[section]) do
42 -%>
43 <%-=string.format("%q", val.option) .. ":" .. string.format("%q", striptags(val.title))-%>
44 <%-if next(self.optionals[section], i) then-%>,<%-end-%>
45 <%-
46 end
47 -%>
48 }, '', '<%-: -- custom -- -%>');
49 </script>
50 <% end %>
51 <% else %>
52 <select id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>">
53 <option><%: -- Additional Field -- %></option>
54 <% for key, val in pairs(self.optionals[section]) do -%>
55 <option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>"><%=striptags(val.title)%></option>
56 <%- end %>
57 </select>
58 <script type="text/javascript"><% for key, val in pairs(self.optionals[section]) do %>
59 <% if #val.deps > 0 then %><% for j, d in ipairs(val.deps) do -%>
60 cbi_d_add("cbi-<%=self.config.."-"..section.."-"..val.option..d.add%>", {
61 <%-
62 for k,v in pairs(d.deps) do
63 -%>
64 <%-=string.format('"cbid.%s.%s.%s"', self.config, section, k) .. ":" .. string.format("%q", v)-%>
65 <%-if next(d.deps, k) then-%>,<%-end-%>
66 <%-
67 end
68 -%>
69 });
70 <%- end %><% end %>
71 <% end %></script>
72 <% end %>
73 <input type="submit" class="cbi-button cbi-button-fieldadd" value="<%:Add%>" />
74 </div>
75 <% end %>