Changeset 6131

Show
Ignore:
Timestamp:
04/27/10 08:25:20 (3 years ago)
Author:
jow
Message:

libs/cbi: fix crash with tabless sections

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • luci/trunk/libs/cbi/luasrc/cbi.lua

    r6130 r6131  
    765765end 
    766766 
     767-- Check whether the section has tabs 
     768function AbstractSection.has_tabs(self) 
     769    return (self.tabs ~= nil) and (next(self.tabs) ~= nil) 
     770end 
     771 
    767772-- Appends a new option 
    768773function AbstractSection.option(self, class, option, ...) 
     
    814819    local field = self.map:formvalue("cbi.opt."..self.config.."."..section) 
    815820    for k,v in ipairs(self.children) do 
    816         if v.optional and not v:cfgvalue(section) and not next(self.tabs) then 
     821        if v.optional and not v:cfgvalue(section) and not self:has_tabs() then 
    817822            if field == v.option then 
    818823                field = nil 
     
    12911296-- Render if this value exists or if it is mandatory 
    12921297function AbstractValue.render(self, s, scope) 
    1293     if not self.optional or next(self.section.tabs) or self:cfgvalue(s) or self:formcreated(s) then 
     1298    if not self.optional or self.section:has_tabs() or self:cfgvalue(s) or self:formcreated(s) then 
    12941299        scope = scope or {} 
    12951300        scope.section   = s