CBI-UVL Validation Integration part #1
[project/luci.git] / libs / cbi / luasrc / view / cbi / ucisection.htm
index f6652fb..c245940 100644 (file)
@@ -12,23 +12,41 @@ You may obtain a copy of the License at
 $Id$
 
 -%>
+
 <% self:render_children(section, scope or {}) %>
-                                               <% if #self.optionals[section] > 0 or self.dynamic then %>
-                                                       <div class="cbi-optionals">
-                                                       <% if self.dynamic then %>
-                                                               <input type="text" name="cbi.opt.<%=self.config%>.<%=section%>" />
-                                                       <% else %>
-                                                               <select name="cbi.opt.<%=self.config%>.<%=section%>">
-                                                                       <option><%:cbi_addopt%></option>
-                                                               <% for key, val in pairs(self.optionals[section]) do %>
-                                                                       <option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>"><%=val.title%></option>
-                                                               <% end %>
-                                                               </select>
-                                                               <script type="text/javascript"><% for key, val in pairs(self.optionals[section]) do %>
-                                                                       <% if #val.deps > 0 then %><% for j, d in ipairs(val.deps) do %>cbi_d_add("cbi-<%=self.config.."-"..section.."-"..val.option%>", "cbid.<%=self.config.."."..section.."."..d.field%>", "<%=d.value%>");
-                                                               <% end %><% end %>
-                                                               <% end %></script>
-                                                       <% end %>
-                                                               <input type="submit" value="<%:add%>" />
-                                                       </div>
-                                               <% end %>
\ No newline at end of file
+
+<% if #self.optionals[section] > 0 or self.dynamic then %>
+       <% if self.tag_deperror[section] then -%>
+               <div class="cbi-error"><%:cbi_deperror%></div>
+       <% elseif self.tag_invalid[section] then -%>
+               <div class="cbi-error"><%:cbi_invalid_section%></div>
+       <%- elseif self.tag_error[section] then -%>
+               <div class="cbi-error"><%=self.tag_error[section]%></div>
+       <%- end %>
+       <div class="cbi-optionals">
+               <% if self.dynamic then %>
+                       <input type="text" name="cbi.opt.<%=self.config%>.<%=section%>" />
+               <% else %>
+               <select name="cbi.opt.<%=self.config%>.<%=section%>">
+                       <option><%:cbi_addopt%></option>
+                       <% for key, val in pairs(self.optionals[section]) do -%>
+                               <option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>"><%=striptags(val.title)%></option>
+                       <%- end %>
+               </select>
+               <script type="text/javascript"><% for key, val in pairs(self.optionals[section]) do %>
+                       <% if #val.deps > 0 then %><% for j, d in ipairs(val.deps) do -%>
+                       cbi_d_add("cbi-<%=self.config.."-"..section.."-"..val.option..d.add%>", {
+               <%-
+                       for k,v in pairs(d.deps) do
+               -%>
+                       <%-=string.format('"cbid.%s.%s.%s"', self.config, section, k) .. ":" .. string.format("%q", v)-%>,
+               <%-
+                       end
+               -%>
+                       });
+               <%- end %><% end %>
+               <% end %></script>
+       <% end %>
+               <input type="submit" class="cbi-button cbi-button-fieldadd" value="<%:add%>" />
+       </div>
+<% end %>