From: Steven Barth Date: Sat, 7 Mar 2009 11:30:41 +0000 (+0000) Subject: Allow combination of SimpleForms as Forms into pages with Maps X-Git-Tag: 0.9.0~621 X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=commitdiff_plain;h=ad57125f4132bef88ff0d2b4e34281ff812dc08b Allow combination of SimpleForms as Forms into pages with Maps Allow subsequent changes of Table data --- diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua index 275c3f3c3..b6ccc5480 100644 --- a/libs/cbi/luasrc/cbi.lua +++ b/libs/cbi/luasrc/cbi.lua @@ -644,6 +644,13 @@ function SimpleForm.get_scheme() end +Form = class(SimpleForm) + +function Form.__init__(self, ...) + SimpleForm.__init__(self, ...) + self.embedded = true +end + --[[ AbstractSection @@ -814,15 +821,16 @@ Table = class(AbstractSection) function Table.__init__(self, form, data, ...) local datasource = {} + local tself = self datasource.config = "table" - self.data = data + self.data = data or {} datasource.formvalue = Map.formvalue datasource.formvaluetable = Map.formvaluetable datasource.readinput = true function datasource.get(self, section, option) - return data[section] and data[section][option] + return tself.data[section] and tself.data[section][option] end function datasource.submitstate(self) @@ -862,6 +870,10 @@ function Table.cfgsections(self) return sections end +function Table.update(self, data) + self.data = data +end + --[[ diff --git a/libs/cbi/luasrc/view/cbi/simpleform.htm b/libs/cbi/luasrc/view/cbi/simpleform.htm index 66810a071..e167a6e6d 100644 --- a/libs/cbi/luasrc/view/cbi/simpleform.htm +++ b/libs/cbi/luasrc/view/cbi/simpleform.htm @@ -12,12 +12,13 @@ You may obtain a copy of the License at $Id$ -%> - +<% if not self.embedded then %>
+<% end %>

<%=self.title%>

<%=self.description%>
@@ -30,6 +31,7 @@ $Id$ <%- if self.errmessage then %>
<%=self.errmessage%>
<%- end %> +<% if not self.embedded then %>
<%- if self.submit ~= false then %> cbi_d_update();
+<% end %>