summaryrefslogtreecommitdiffhomepage
path: root/libs/web/luasrc/view/cbi/ucisection.htm
blob: db32c904390734f8f442e75723f5d6aee1e8ba76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<%#
LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

$Id$

-%>

<%-
	if type(self.hidden) == "table" then
		for k, v in pairs(self.hidden) do
-%>
	<input type="hidden" id="<%=k%>" name="<%=k%>" value="<%=pcdata(v)%>" />
<%-
		end
	end
%>

<% if self.tabs then %>
	<%+cbi/tabcontainer%>
<% else %>
	<% self:render_children(section, scope or {}) %>
<% end %>

<% if self.error and self.error[section] then -%>
	<div class="cbi-section-error">
		<ul><% for _, e in ipairs(self.error[section]) do -%>
			<li>
				<%- if e == "invalid" then -%>
					<%:One or more fields contain invalid values!%>
				<%- elseif e == "missing" then -%>
					<%:One or more required fields have no value!%>
				<%- else -%>
					<%=pcdata(e)%>
				<%- end -%>
			</li>
		<%- end %></ul>
	</div>
<%- end %>

<% if self.optionals[section] and #self.optionals[section] > 0 or self.dynamic then %>
	<div class="cbi-optionals">
		<% if self.dynamic then %>
			<input type="text" id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>" />
			<% if self.optionals[section] and #self.optionals[section] > 0 then %>
			<script type="text/javascript">
				cbi_combobox_init('cbi.opt.<%=self.config%>.<%=section%>', {
				<%-
					for i, val in pairs(self.optionals[section]) do
				-%>
					<%-=string.format("%q", val.option) .. ":" .. string.format("%q", striptags(val.title))-%>
					<%-if next(self.optionals[section], i) then-%>,<%-end-%>
				<%-
					end
				-%>
				}, '', '<%-: -- custom -- -%>');
			</script>
			<% end %>
		<% else %>
		<select id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>">
			<option><%: -- Additional Field -- %></option>
			<% for key, val in pairs(self.optionals[section]) do -%>
				<option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>"><%=striptags(val.title)%></option>
			<%- end %>
		</select>
		<script type="text/javascript"><% for key, val in pairs(self.optionals[section]) do %>
			<% if #val.deps > 0 then %><% for j, d in ipairs(val.deps) do -%>
			cbi_d_add("cbi-<%=self.config.."-"..section.."-"..val.option..d.add%>", {
		<%-
			for k,v in pairs(d.deps) do
		-%>
			<%-=string.format('"cbid.%s.%s.%s"', self.config, section, k) .. ":" .. string.format("%q", v)-%>
			<%-if next(d.deps, k) then-%>,<%-end-%>
		<%-
			end
		-%>
			});
		<%- end %><% end %>
		<% end %></script>
	<% end %>
		<input type="submit" class="cbi-button cbi-button-fieldadd" value="<%:Add%>" />
	</div>
<% end %>