summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-compat/luasrc/view/cbi/simpleform.htm
blob: 9e1514546e6ab11d7f783c79285efa18c43d772a (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
<%
	if not self.embedded then
		%><form method="post" enctype="multipart/form-data" action="<%=REQUEST_URI%>">
			<input type="hidden" name="token" value="<%=token%>" />
			<input type="hidden" name="cbi.submit" value="1" /><%
	end

	%><div class="cbi-map" id="cbi-<%=self.config%>"><%

	if self.title and #self.title > 0 then
		%><h2 name="content"><%=self.title%></h2><%
	end

	if self.description and #self.description > 0 then
		%><div class="cbi-map-descr"><%=self.description%></div><%
	end

	self:render_children()

	%></div><%

	if self.message then
		%><div class="alert-message notice"><%=self.message%></div><%
	end

	if self.errmessage then
		%><div class="alert-message warning"><%=self.errmessage%></div><%
	end

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

		local display_back   = (redirect)
		local display_cancel = (self.cancel ~= false and self.on_cancel)
		local display_skip   = (self.flow and self.flow.skip)
		local display_submit = (self.submit ~= false)
		local display_reset  = (self.reset ~= false)

		if display_back or display_cancel or display_skip or display_submit or display_reset then
			%><div class="cbi-page-actions"><%

			if display_back then
				%><input class="btn cbi-button cbi-button-link" type="button" value="<%:Back to Overview%>" onclick="location.href='<%=pcdata(redirect)%>'" /> <%
			end

			if display_cancel then
				local label = pcdata(self.cancel or translate("Cancel"))
				%><input class="btn cbi-button cbi-button-link" type="button" value="<%=label%>" onclick="cbi_submit(this, 'cbi.cancel')" /> <%
			end

			if display_skip then
				%><input class="btn cbi-button cbi-button-neutral" type="button" value="<%:Skip%>" onclick="cbi_submit(this, 'cbi.skip')" /> <%
			end

			if display_submit then
				local label = pcdata(self.submit or translate("Submit"))
				%><input class="btn cbi-button cbi-button-save" type="submit" value="<%=label%>" /> <%
			end

			if display_reset then
				local label = pcdata(self.reset or translate("Reset"))
				%><input class="btn cbi-button cbi-button-reset" type="reset" value="<%=label%>" /> <%
			end

			%></div><%
		end

		%></form><%
	end
%>

<script type="text/javascript">cbi_init();</script>