libs/web: skip empty values in DynList widget
[project/luci.git] / libs / web / luasrc / view / cbi / dynlist.htm
index 9ca7534..90f3f1e 100644 (file)
@@ -18,9 +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
 %>
-       <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")%> /><br />
-<% end %>
+       <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") ..
+               ifattr(i == 1 and self.placeholder, "placeholder", self.placeholder)
+       %> /><br />
+<% end end %>
 </div>
 <script type="text/javascript">
 cbi_dynlist_init('<%=cbid%>');
@@ -36,7 +40,7 @@ cbi_dynlist_init('<%=cbid%>');
                <%- end -%>', '<%: -- custom -- %>');
        <% end -%>
        <% for i=1, #vals + 1 do -%>
-       cbi_validate_field('<%=cbid%>.<%=i%>', <%=tostring(self.optional == true or i > #vals)%>, '<%=self.datatype%>');
+       cbi_validate_field('<%=cbid%>.<%=i%>', <%=tostring((self.optional or self.rmempty) == true or i > #vals)%>, '<%=self.datatype%>');
        <%- end %>
 <% end -%>
 </script>