summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2010-04-27 07:25:20 +0000
committerJo-Philipp Wich <jow@openwrt.org>2010-04-27 07:25:20 +0000
commit4dc420efd355a732119cbbc01bff7ff9a32f80a7 (patch)
tree7201a082fda5ba2c26531c269944d9fb8a21c4d6
parenteca5a0abf07d6c4a08278bec9c578bdf294929c8 (diff)
libs/cbi: fix crash with tabless sections
-rw-r--r--libs/cbi/luasrc/cbi.lua9
1 files changed, 7 insertions, 2 deletions
diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua
index cc22229fc..fff88a227 100644
--- a/libs/cbi/luasrc/cbi.lua
+++ b/libs/cbi/luasrc/cbi.lua
@@ -764,6 +764,11 @@ function AbstractSection.tab(self, tab, title, desc)
}
end
+-- Check whether the section has tabs
+function AbstractSection.has_tabs(self)
+ return (self.tabs ~= nil) and (next(self.tabs) ~= nil)
+end
+
-- Appends a new option
function AbstractSection.option(self, class, option, ...)
if instanceof(class, AbstractValue) then
@@ -813,7 +818,7 @@ function AbstractSection.parse_optionals(self, section)
local field = self.map:formvalue("cbi.opt."..self.config.."."..section)
for k,v in ipairs(self.children) do
- if v.optional and not v:cfgvalue(section) and not next(self.tabs) then
+ if v.optional and not v:cfgvalue(section) and not self:has_tabs() then
if field == v.option then
field = nil
self.map.proceed = true
@@ -1290,7 +1295,7 @@ end
-- Render if this value exists or if it is mandatory
function AbstractValue.render(self, s, scope)
- if not self.optional or next(self.section.tabs) or self:cfgvalue(s) or self:formcreated(s) then
+ if not self.optional or self.section:has_tabs() or self:cfgvalue(s) or self:formcreated(s) then
scope = scope or {}
scope.section = s
scope.cbid = self:cbid(s)