From 19c79a30b91354932b12ffb9f866471b06a570df Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Sun, 7 Sep 2008 23:50:58 +0000 Subject: Fixed DHCP-Options and some CBI stuff --- libs/cbi/luasrc/cbi.lua | 9 ++++++--- libs/cbi/luasrc/view/cbi/dynlist.htm | 2 +- libs/cbi/luasrc/view/cbi/mvalue.htm | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'libs/cbi') diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua index 30727cef22..df7f292522 100644 --- a/libs/cbi/luasrc/cbi.lua +++ b/libs/cbi/luasrc/cbi.lua @@ -933,7 +933,7 @@ function AbstractValue.parse(self, section) local fvalue = self:formvalue(section) local cvalue = self:cfgvalue(section) - if fvalue and fvalue ~= "" then -- If we have a form value, write it to UCI + if fvalue and #fvalue > 0 then -- If we have a form value, write it to UCI fvalue = self:transform(self:validate(fvalue, section)) if not fvalue then self.tag_invalid[section] = true @@ -983,7 +983,9 @@ end -- Return the UCI value of this object function AbstractValue.cfgvalue(self, section) local value = self.map:get(section, self.option) - if not self.cast or self.cast == type(value) then + if not value then + return nil + elseif not self.cast or self.cast == type(value) then return value elseif self.cast == "string" then if type(value) == "table" then @@ -1251,7 +1253,8 @@ function DynamicList.value(self, key, val) table.insert(self.vallist, tostring(val)) end -function DynamicList.validate(self, value, section) +function DynamicList.formvalue(self, section) + local value = AbstractValue.formvalue(self, section) value = (type(value) == "table") and value or {value} local valid = {} diff --git a/libs/cbi/luasrc/view/cbi/dynlist.htm b/libs/cbi/luasrc/view/cbi/dynlist.htm index 1d28f95d9b..1cfd6f03e5 100644 --- a/libs/cbi/luasrc/view/cbi/dynlist.htm +++ b/libs/cbi/luasrc/view/cbi/dynlist.htm @@ -14,7 +14,7 @@ $Id$ -%> <%+cbi/valueheader%> <% - local vals = self:cfgvalue(section) + local vals = self:cfgvalue(section) or {} for i=1, #vals + 1 do local val = vals[i] %> diff --git a/libs/cbi/luasrc/view/cbi/mvalue.htm b/libs/cbi/luasrc/view/cbi/mvalue.htm index 4b69708ecd..414089fb2e 100644 --- a/libs/cbi/luasrc/view/cbi/mvalue.htm +++ b/libs/cbi/luasrc/view/cbi/mvalue.htm @@ -13,7 +13,7 @@ $Id$ -%> <% -local v = self:valuelist(section) +local v = self:valuelist(section) or {} %> <%+cbi/valueheader%> <% if self.widget == "select" then %> -- cgit v1.2.3