libs/web: skip empty values in DynList widget
This commit is contained in:
parent
aa0f710867
commit
ff58e81d18
2 changed files with 8 additions and 3 deletions
|
@ -1662,7 +1662,9 @@ function DynamicList.write(self, section, value)
|
||||||
elseif self.cast == "table" and type(value) == "string" then
|
elseif self.cast == "table" and type(value) == "string" then
|
||||||
local x, t = { }
|
local x, t = { }
|
||||||
for x in value:gmatch("%S+") do
|
for x in value:gmatch("%S+") do
|
||||||
t[#t+1] = x
|
if #x > 0 then
|
||||||
|
t[#t+1] = x
|
||||||
|
end
|
||||||
end
|
end
|
||||||
value = t
|
value = t
|
||||||
end
|
end
|
||||||
|
@ -1677,7 +1679,9 @@ function DynamicList.cfgvalue(self, section)
|
||||||
local x
|
local x
|
||||||
local t = { }
|
local t = { }
|
||||||
for x in value:gmatch("%S+") do
|
for x in value:gmatch("%S+") do
|
||||||
t[#t+1] = x
|
if #x > 0 then
|
||||||
|
t[#t+1] = x
|
||||||
|
end
|
||||||
end
|
end
|
||||||
value = t
|
value = t
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,12 +18,13 @@ $Id$
|
||||||
local vals = self:cfgvalue(section) or {}
|
local vals = self:cfgvalue(section) or {}
|
||||||
for i=1, #vals + 1 do
|
for i=1, #vals + 1 do
|
||||||
local val = vals[i]
|
local val = vals[i]
|
||||||
|
if val and #val > 0 then
|
||||||
%>
|
%>
|
||||||
<input class="cbi-input-text" value="<%=pcdata(val)%>" onchange="cbi_d_update(this.id)" type="text"<%=
|
<input class="cbi-input-text" value="<%=pcdata(val)%>" onchange="cbi_d_update(this.id)" type="text"<%=
|
||||||
attr("id", cbid .. "." .. i) .. attr("name", cbid) .. ifattr(self.size, "size") ..
|
attr("id", cbid .. "." .. i) .. attr("name", cbid) .. ifattr(self.size, "size") ..
|
||||||
ifattr(i == 1 and self.placeholder, "placeholder", self.placeholder)
|
ifattr(i == 1 and self.placeholder, "placeholder", self.placeholder)
|
||||||
%> /><br />
|
%> /><br />
|
||||||
<% end %>
|
<% end end %>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
cbi_dynlist_init('<%=cbid%>');
|
cbi_dynlist_init('<%=cbid%>');
|
||||||
|
|
Loading…
Reference in a new issue