1
0

ucisection.htm 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <%-
  2. if type(self.hidden) == "table" then
  3. for k, v in pairs(self.hidden) do
  4. -%>
  5. <input type="hidden" id="<%=k%>" name="<%=k%>" value="<%=pcdata(v)%>" />
  6. <%-
  7. end
  8. end
  9. %>
  10. <% if self.tabs then %>
  11. <%+cbi/tabcontainer%>
  12. <% else %>
  13. <% self:render_children(section, scope or {}) %>
  14. <% end %>
  15. <% if self.error and self.error[section] then -%>
  16. <div class="cbi-section-error" data-index="<%=#self.children + 1%>">
  17. <ul><% for _, e in ipairs(self.error[section]) do -%>
  18. <li>
  19. <%- if e == "invalid" then -%>
  20. <%:One or more fields contain invalid values!%>
  21. <%- elseif e == "missing" then -%>
  22. <%:One or more required fields have no value!%>
  23. <%- else -%>
  24. <%=pcdata(e)%>
  25. <%- end -%>
  26. </li>
  27. <%- end %></ul>
  28. </div>
  29. <%- end %>
  30. <% if self.optionals[section] and #self.optionals[section] > 0 or self.dynamic then %>
  31. <div class="cbi-optionals" data-index="<%=#self.children + 1%>">
  32. <%-
  33. if self.dynamic then
  34. local keys, vals, name, opt = { }, { }
  35. for name, opt in pairs(self.optionals[section]) do
  36. keys[#keys+1] = name
  37. vals[#vals+1] = opt.title
  38. end
  39. -%>
  40. <input type="text" id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>" data-type="uciname" data-optional="true"<%=
  41. ifattr(#keys > 0, "data-choices", luci.util.json_encode({keys, vals}))
  42. %> />
  43. <%- else -%>
  44. <select id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>" data-optionals="true">
  45. <option><%: -- Additional Field -- %></option>
  46. <% for key, val in pairs(self.optionals[section]) do -%>
  47. <option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>" data-index="<%=val.index%>" data-depends="<%=pcdata(val:deplist2json(section))%>"><%=striptags(val.title)%></option>
  48. <%- end %>
  49. </select>
  50. <%- end -%>
  51. <input type="submit" class="cbi-button cbi-button-fieldadd" value="<%:Add%>" />
  52. </div>
  53. <% end %>