libs/web: support local destination in zonelist widget
[project/luci.git] / libs / web / 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="<%=k%>" name="<%=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 -%>
35                         <li>
36                                 <%- if e == "invalid" then -%>
37                                         <%:One or more fields contain invalid values!%>
38                                 <%- elseif e == "missing" then -%>
39                                         <%:One or more required fields have no value!%>
40                                 <%- else -%>
41                                         <%=pcdata(e)%>
42                                 <%- end -%>
43                         </li>
44                 <%- end %></ul>
45         </div>
46 <%- end %>
47
48 <% if self.optionals[section] and #self.optionals[section] > 0 or self.dynamic then %>
49         <div class="cbi-optionals">
50                 <% if self.dynamic then %>
51                         <input type="text" id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>" />
52                         <% if self.optionals[section] and #self.optionals[section] > 0 then %>
53                         <script type="text/javascript">
54                                 cbi_combobox_init('cbi.opt.<%=self.config%>.<%=section%>', {
55                                 <%-
56                                         for i, val in pairs(self.optionals[section]) do
57                                 -%>
58                                         <%-=string.format("%q", val.option) .. ":" .. string.format("%q", striptags(val.title))-%>
59                                         <%-if next(self.optionals[section], i) then-%>,<%-end-%>
60                                 <%-
61                                         end
62                                 -%>
63                                 }, '', '<%-: -- custom -- -%>');
64                         </script>
65                         <% end %>
66                 <% else %>
67                 <select id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>">
68                         <option><%: -- Additional Field -- %></option>
69                         <% for key, val in pairs(self.optionals[section]) do -%>
70                                 <option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>"><%=striptags(val.title)%></option>
71                         <%- end %>
72                 </select>
73                 <script type="text/javascript"><% for key, val in pairs(self.optionals[section]) do %>
74                         <% if #val.deps > 0 then %><% for j, d in ipairs(val.deps) do -%>
75                         cbi_d_add("cbi-<%=self.config.."-"..section.."-"..val.option..d.add%>", {
76                 <%-
77                         for k,v in pairs(d.deps) do
78                 -%>
79                         <%-=string.format('"cbid.%s.%s.%s"', self.config, section, k) .. ":" .. string.format("%q", v)-%>
80                         <%-if next(d.deps, k) then-%>,<%-end-%>
81                 <%-
82                         end
83                 -%>
84                         });
85                 <%- end %><% end %>
86                 <% end %></script>
87         <% end %>
88                 <input type="submit" class="cbi-button cbi-button-fieldadd" value="<%:Add%>" />
89         </div>
90 <% end %>