1
0

dropdown.htm 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <%+cbi/valueheader%>
  2. <%-
  3. local selected = { }
  4. if self.multiple then
  5. local val
  6. for val in luci.util.imatch(self:cfgvalue(section)) do
  7. selected[val] = true
  8. end
  9. else
  10. selected[self:cfgvalue(section)] = true
  11. end
  12. if not next(selected) and self.default then
  13. selected[self.default] = true
  14. end
  15. -%>
  16. <div class="cbi-dropdown"<%=
  17. attr("name", cbid) ..
  18. attr("display-items", self.display or self.size or 3) ..
  19. attr("dropdown-items", self.dropdown or self.display or self.size or 5) ..
  20. attr("placeholder", self.placeholder or translate("-- please select --")) ..
  21. ifattr(self.multiple, "multiple", "multiple") ..
  22. ifattr(self.optional or self.rmempty, "optional", "optional")
  23. %>>
  24. <ul>
  25. <% local i, key; for i, key in pairs(self.keylist) do %>
  26. <li<%=
  27. attr("data-index", i) ..
  28. attr("data-depends", self:deplist2json(section, self.deplist[i])) ..
  29. attr("data-value", key) ..
  30. ifattr(selected[key], "selected", "selected")
  31. %>>
  32. <%=pcdata(self.vallist[i])%>
  33. </li>
  34. <% end %>
  35. <% if self.custom then %>
  36. <li>
  37. <input type="password" style="display:none" />
  38. <input class="create-item-input" type="text"<%=
  39. attr("placeholder", self.custom ~= true and
  40. self.custom or
  41. (self.multiple and
  42. translate("Enter custom values") or
  43. translate("Enter custom value")))
  44. %> />
  45. </li>
  46. <% end %>
  47. </ul>
  48. </div>
  49. <%+cbi/valuefooter%>