Extend CBI state handling
authorSteven Barth <steven@midlink.org>
Sat, 1 Nov 2008 18:32:02 +0000 (18:32 +0000)
committerSteven Barth <steven@midlink.org>
Sat, 1 Nov 2008 18:32:02 +0000 (18:32 +0000)
libs/cbi/luasrc/cbi.lua
libs/web/luasrc/dispatcher.lua

index ff5296e..328722f 100644 (file)
@@ -352,13 +352,15 @@ function Map.parse(self)
 
        if self:submitstate() then
                if self.save then
 
        if self:submitstate() then
                if self.save then
-                       return self.changed and FORM_CHANGED or FORM_VALID
+                       self.state = self.changed and FORM_CHANGED or FORM_VALID
                else
                else
-                       return FORM_INVALID
+                       self.state = FORM_INVALID
                end
        else
                end
        else
-               return FORM_NODATA
+               self.state = FORM_NODATA
        end
        end
+
+       return self.state
 end
 
 function Map.render(self, ...)
 end
 
 function Map.render(self, ...)
index 51f6d96..22d9dd9 100644 (file)
@@ -521,6 +521,12 @@ function cbi(model, config)
                        end
                end
 
                        end
                end
 
+               if config.state_handler then
+                       if not config.state_handler(state, maps) then
+                               return
+                       end
+               end
+
                local pageaction = true
                http.header("X-CBI-State", state or 0)
                luci.template.render("cbi/header", {state = state})
                local pageaction = true
                http.header("X-CBI-State", state or 0)
                luci.template.render("cbi/header", {state = state})