+ return self.uci:get(self.config, section, option)
+ else
+ return self.uci:get_all(self.config, section)
+ end
+end
+
+
+--[[
+Page - A simple node
+]]--
+
+Page = class(Node)
+Page.__init__ = Node.__init__
+Page.parse = function() end
+
+
+--[[
+SimpleForm - A Simple non-UCI form
+]]--
+SimpleForm = class(Node)
+
+function SimpleForm.__init__(self, config, title, description, data)
+ Node.__init__(self, title, description)
+ self.config = config
+ self.data = data or {}
+ self.template = "cbi/simpleform"
+ self.dorender = true
+end
+
+function SimpleForm.parse(self, ...)
+ if luci.http.formvalue("cbi.submit") then
+ Node.parse(self, 1, ...)
+ end
+
+ local valid = true
+ for k, j in ipairs(self.children) do
+ for i, v in ipairs(j.children) do
+ valid = valid
+ and (not v.tag_missing or not v.tag_missing[1])
+ and (not v.tag_invalid or not v.tag_invalid[1])
+ end
+ end
+
+ local state =
+ not luci.http.formvalue("cbi.submit") and 0
+ or valid and 1
+ or -1
+
+ self.dorender = not self.handle or self:handle(state, self.data) ~= false
+end
+
+function SimpleForm.render(self, ...)
+ if self.dorender then
+ Node.render(self, ...)
+ end
+end
+
+function SimpleForm.section(self, class, ...)
+ if instanceof(class, AbstractSection) then
+ local obj = class(self, ...)
+ self:append(obj)
+ return obj
+ else
+ error("class must be a descendent of AbstractSection")
+ end
+end
+
+-- Creates a child field
+function SimpleForm.field(self, class, ...)
+ local section
+ for k, v in ipairs(self.children) do
+ if instanceof(v, SimpleSection) then
+ section = v
+ break
+ end
+ end
+ if not section then
+ section = self:section(SimpleSection)
+ end
+
+ if instanceof(class, AbstractValue) then
+ local obj = class(self, ...)
+ obj.track_missing = true
+ section:append(obj)
+ return obj