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 ff5296e35f7aab2506ade37ec4ee9bb604aa209e..328722f9ab0895a070b20141b65100614babbd4f 100644 (file)
@@ -352,13 +352,15 @@ function Map.parse(self)
 
        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
-                       return FORM_INVALID
+                       self.state = FORM_INVALID
                end
        else
-               return FORM_NODATA
+               self.state = FORM_NODATA
        end
+
+       return self.state
 end
 
 function Map.render(self, ...)
index 51f6d9695fd08f07f8594a69798fdf9df695f241..22d9dd9bc323f9f2df1eecfc6a97b7274e3f7b0b 100644 (file)
@@ -521,6 +521,12 @@ function cbi(model, config)
                        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})