luci-base: cbi: fix dependency handling of list and multivalues with radio/checkbox...
[project/luci.git] / modules / luci-base / luasrc / view / cbi / mvalue.htm
1 <%
2         local i, key
3         local v = self:valuelist(section) or {}
4 -%>
5
6 <%+cbi/valueheader%>
7 <% if self.widget == "select" then %>
8         <select class="cbi-input-select" multiple="multiple" data-update="click change"<%=
9                 attr("id", cbid) ..
10                 attr("name", cbid) ..
11                 ifattr(self.size, "size")
12         %>>
13                 <% for i, key in pairs(self.keylist) do -%>
14                         <option<%=
15                                 attr("id", cbid.."-"..key) ..
16                                 attr("value", key) ..
17                                 attr("data-index", i) ..
18                                 attr("data-depends", self:deplist2json(section, self.deplist[i])) ..
19                                 ifattr(luci.util.contains(v, key), "selected", "selected")
20                         %>><%=pcdata(self.vallist[i])%></option>
21                 <%- end %>
22         </select>
23 <% elseif self.widget == "checkbox" then %>
24         <div>
25                 <% for i, key in pairs(self.keylist) do %>
26                         <label<%=
27                                 attr("id", cbid.."-"..key) ..
28                                 attr("data-index", i) ..
29                                 attr("data-depends", self:deplist2json(section, self.deplist[i]))
30                         %>>
31                                 <input class="cbi-input-checkbox" type="checkbox" data-update="click change"<%=
32                                         attr("name", cbid) ..
33                                         attr("value", key) ..
34                                         ifattr(luci.util.contains(v, key), "checked", "checked")
35                                 %> />
36                                 <%=pcdata(self.vallist[i])%>
37                         </label>
38                         <% if i == self.size then write('<br />') end %>
39                 <% end %>
40         </div>
41 <% end %>
42 <%+cbi/valuefooter%>