or valid and 1
or -1
- self.dorender = self:handle(state, self.data) ~= false
+ self.dorender = not self.handle or self:handle(state, self.data) ~= false
end
function SimpleForm.render(self, ...)
self.data = data
function datasource.get(self, section, option)
- return data[section][option]
+ return data[section] and data[section][option]
+ end
+
+ function datasource.del(...)
+ return true
end
AbstractSection.__init__(self, datasource, "table", ...)
self.anonymous = true
end
+function Table.parse(self)
+ for i, k in ipairs(self:cfgsections()) do
+ if luci.http.formvalue("cbi.submit") then
+ Node.parse(self, k)
+ end
+ end
+end
+
function Table.cfgsections(self)
local sections = {}
- for i, v in pairs(self.data) do
+ for i, v in luci.util.kspairs(self.data) do
table.insert(sections, i)
end
self.config = map.config
self.tag_invalid = {}
self.tag_missing = {}
+ self.tag_error = {}
self.deps = {}
self.track_missing = false
table.insert(self.deps, {field=field, value=value})
end
+-- Generates the unique CBID
+function AbstractValue.cbid(self, section)
+ return "cbid."..self.map.config.."."..section.."."..self.option
+end
+
-- Return whether this object should be created
function AbstractValue.formcreated(self, section)
local key = "cbi.opt."..self.config.."."..section
-- Returns the formvalue for this object
function AbstractValue.formvalue(self, section)
- local key = "cbid."..self.map.config.."."..section.."."..self.option
- return luci.http.formvalue(key)
+ return luci.http.formvalue(self:cbid(section))
end
function AbstractValue.additional(self, value)
if not self.optional or self:cfgvalue(s) or self:formcreated(s) then
scope = scope or {}
scope.section = s
- scope.cbid = "cbid." .. self.config ..
- "." .. s ..
- "." .. self.option
+ scope.cbid = self:cbid(s)
scope.ifattr = function(cond,key,val)
if cond then
AbstractValue.__init__(self, ...)
self.template = "cbi/tvalue"
end
+
+--[[
+Button
+]]--
+Button = class(AbstractValue)
+
+function Button.__init__(self, ...)
+ AbstractValue.__init__(self, ...)
+ self.template = "cbi/button"
+ self.inputstyle = nil
+ self.rmempty = true
+end
\ No newline at end of file