* luci/libs/cbi: fix error assignment in cbi sections
authorJo-Philipp Wich <jow@openwrt.org>
Sat, 6 Sep 2008 22:37:56 +0000 (22:37 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sat, 6 Sep 2008 22:37:56 +0000 (22:37 +0000)
libs/cbi/luasrc/cbi.lua
libs/cbi/luasrc/view/cbi/cell_valueheader.htm
libs/cbi/luasrc/view/cbi/full_valueheader.htm
libs/cbi/luasrc/view/cbi/tblsection.htm
libs/cbi/luasrc/view/cbi/ucisection.htm

index 09ba553..c1eefca 100644 (file)
@@ -89,7 +89,11 @@ local function _uvl_validate_section(node, name)
 
        local function tag_fields(e)
                if e.option and node.fields[e.option] then
-                       node.fields[e.option].error = e
+                       if node.fields[e.option].error then
+                               node.fields[e.option].error[name] = e
+                       else
+                               node.fields[e.option].error = { [name] = e }
+                       end
                elseif e.childs then
                        for _, c in ipairs(e.childs) do tag_fields(c) end
                end
@@ -104,7 +108,13 @@ local function _uvl_validate_section(node, name)
                                table.insert( s, c:string() )
                        end
                end
-               if #s > 0 then node.error = s end
+               if #s > 0 then
+                       if node.error then
+                               node.error[name] = s
+                       else
+                               node.error = { [name] = s }
+                       end
+               end
        end
 
        local stat, err = node.map.validator:validate_section(node.config, name, co)
index 9a065a3..dda1746 100644 (file)
@@ -13,4 +13,4 @@ $Id$
 
 -%>
 
-<td class="cbi-value-field<% if self.error then %> cbi-value-error<% end %>" id="cbi-<%=self.config.."-"..section.."-"..self.option%>">
+<td class="cbi-value-field<% if self.error and self.error[section] then %> cbi-value-error<% end %>" id="cbi-<%=self.config.."-"..section.."-"..self.option%>">
index fed2412..cbeda75 100644 (file)
@@ -13,7 +13,7 @@ $Id$
 
 -%>
 
-<div class="cbi-value<% if self.error then %> cbi-value-error<% end %>" id="cbi-<%=self.config.."-"..section.."-"..self.option%>">
+<div class="cbi-value<% if self.error and self.error[section] then %> cbi-value-error<% end %>" id="cbi-<%=self.config.."-"..section.."-"..self.option%>">
        <%- if self.title and #self.title > 0 then -%>
        <label class="cbi-value-title"<%= attr("for", cbid) %>>
        <%- if self.titleref then -%><a title="<%=self.titledesc or translate('cbi_gorel')%>" class="cbi-title-ref" href="<%=self.titleref%>"><%- end -%>
index 5a2b247..49930f8 100644 (file)
@@ -100,7 +100,9 @@ end
 
                <% if self.error then %>
                        <div class="cbi-section-error">
-                               <ul><% for _, e in ipairs(self.error) do %><li><%=luci.util.pcdata(e):gsub("\n","<br />")%></li><% end %></ul>
+                               <ul><% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
+                                       <li><%=luci.util.pcdata(e):gsub("\n","<br />")%></li>
+                               <%- end end %></ul>
                        </div>
                <% end %>
 
index feab18e..92343bb 100644 (file)
@@ -15,9 +15,9 @@ $Id$
 
 <% self:render_children(section, scope or {}) %>
 
-<% if self.error then -%>
+<% if self.error and self.error[section] then -%>
        <div class="cbi-section-error">
-               <ul><% for _, e in ipairs(self.error) do %><li><%=luci.util.pcdata(e):gsub("\n","<br />")%></li><% end %></ul>
+               <ul><% for _, e in ipairs(self.error[section]) do %><li><%=luci.util.pcdata(e):gsub("\n","<br />")%></li><% end %></ul>
        </div>
 <%- end %>