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