luci-base: cbi: fix dependency handling of list and multivalues with radio/checkbox...
[project/luci.git] / modules / luci-base / luasrc / view / cbi / lvalue.htm
1 <%
2         local i, key
3         local br = self.orientation == "horizontal" and '&#160;' or '<br />'
4 %>
5
6 <%+cbi/valueheader%>
7 <% if self.widget == "select" then %>
8         <select class="cbi-input-select" data-update="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(tostring(self:cfgvalue(section) or self.default) == key, "selected", "selected")
20                         %>><%=pcdata(self.vallist[i])%></option>
21                 <%- end %>
22         </select>
23 <% elseif self.widget == "radio" 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-radio" data-update="click change" type="radio"<%=
32                                         attr("name", cbid) ..
33                                         attr("value", key) ..
34                                         ifattr((self:cfgvalue(section) or self.default) == 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%>