From ff58e81d18a23fcbdfea89044b0600bcdd2d06da Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sat, 20 Nov 2010 18:08:18 +0000 Subject: [PATCH] libs/web: skip empty values in DynList widget --- libs/web/luasrc/cbi.lua | 8 ++++++-- libs/web/luasrc/view/cbi/dynlist.htm | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/libs/web/luasrc/cbi.lua b/libs/web/luasrc/cbi.lua index 6c9e7a544..50b594b4c 100644 --- a/libs/web/luasrc/cbi.lua +++ b/libs/web/luasrc/cbi.lua @@ -1662,7 +1662,9 @@ function DynamicList.write(self, section, value) elseif self.cast == "table" and type(value) == "string" then local x, t = { } for x in value:gmatch("%S+") do - t[#t+1] = x + if #x > 0 then + t[#t+1] = x + end end value = t end @@ -1677,7 +1679,9 @@ function DynamicList.cfgvalue(self, section) local x local t = { } for x in value:gmatch("%S+") do - t[#t+1] = x + if #x > 0 then + t[#t+1] = x + end end value = t end diff --git a/libs/web/luasrc/view/cbi/dynlist.htm b/libs/web/luasrc/view/cbi/dynlist.htm index 5f57941b8..90f3f1e90 100644 --- a/libs/web/luasrc/view/cbi/dynlist.htm +++ b/libs/web/luasrc/view/cbi/dynlist.htm @@ -18,12 +18,13 @@ $Id$ local vals = self:cfgvalue(section) or {} for i=1, #vals + 1 do local val = vals[i] + if val and #val > 0 then %> />
-<% end %> +<% end end %>