2cb1e75d0ee27055a8183339648e0d8f71aa9dd2
[project/luci.git] / modules / luci-base / 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" data-index="<%=#self.children + 1%>">
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" data-index="<%=#self.children + 1%>">
35                 <%
36                 if self.dynamic then
37                         local keys, vals, name, opt = { }, { }
38                         for name, opt in pairs(self.optionals[section]) do
39                                 keys[#keys+1] = name
40                                 vals[#vals+1] = opt.title
41                         end
42                 %>
43                         <input type="text" id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>" data-type="uciname" data-optional="true"<%=
44                                 ifattr(#keys > 0, "data-choices", luci.util.json_encode({keys, vals}))
45                         %> />
46                 <% else %>
47                         <select id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>" data-optionals="true">
48                                 <option><%: -- Additional Field -- %></option>
49                                 <% for key, val in pairs(self.optionals[section]) do -%>
50                                         <option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>" data-index="<%=val.index%>" data-depends="<%=pcdata(val:deplist2json(section))%>"><%=striptags(val.title)%></option>
51                                 <%- end %>
52                         </select>
53                 <% end %>
54                 <input type="submit" class="cbi-button cbi-button-fieldadd" value="<%:Add%>" />
55         </div>
56 <% end %>