ucisection.htm 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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">
  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">
  32. <% if self.dynamic then %>
  33. <input type="text" id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>" />
  34. <% if self.optionals[section] and #self.optionals[section] > 0 then %>
  35. <script type="text/javascript">
  36. cbi_combobox_init('cbi.opt.<%=self.config%>.<%=section%>', {
  37. <%-
  38. for i, val in pairs(self.optionals[section]) do
  39. -%>
  40. <%-=string.format("%q", val.option) .. ":" .. string.format("%q", striptags(val.title))-%>
  41. <%-if next(self.optionals[section], i) then-%>,<%-end-%>
  42. <%-
  43. end
  44. -%>
  45. }, '', '<%-: -- custom -- -%>');
  46. </script>
  47. <% end %>
  48. <% else %>
  49. <select id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>">
  50. <option><%: -- Additional Field -- %></option>
  51. <% for key, val in pairs(self.optionals[section]) do -%>
  52. <option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>"><%=striptags(val.title)%></option>
  53. <%- end %>
  54. </select>
  55. <script type="text/javascript"><% for key, val in pairs(self.optionals[section]) do %>
  56. <% if #val.deps > 0 then %><% for j, d in ipairs(val.deps) do -%>
  57. cbi_d_add("cbi-<%=self.config.."-"..section.."-"..val.option..d.add%>", {
  58. <%-
  59. for k,v in pairs(d.deps) do
  60. -%>
  61. <%-=string.format('"cbid.%s.%s.%s"', self.config, section, k) .. ":" .. string.format("%q", v)-%>
  62. <%-if next(d.deps, k) then-%>,<%-end-%>
  63. <%-
  64. end
  65. -%>
  66. });
  67. <%- end %><% end %>
  68. <% end %></script>
  69. <% end %>
  70. <input type="submit" class="cbi-button cbi-button-fieldadd" value="<%:Add%>" />
  71. </div>
  72. <% end %>