diff --git a/package/gluon-web-model/luasrc/usr/lib/lua/gluon/web/model/classes.lua b/package/gluon-web-model/luasrc/usr/lib/lua/gluon/web/model/classes.lua index 7968db0e..e75d12f0 100644 --- a/package/gluon-web-model/luasrc/usr/lib/lua/gluon/web/model/classes.lua +++ b/package/gluon-web-model/luasrc/usr/lib/lua/gluon/web/model/classes.lua @@ -186,6 +186,7 @@ function AbstractValue:__init__(...) self.template = "model/valuewrapper" + self.error = false self.state = M.FORM_NODATA end @@ -205,14 +206,9 @@ function AbstractValue:cfgvalue() end end -function AbstractValue:add_error(type, msg) - self.error = msg or type - self.state = M.FORM_INVALID -end - function AbstractValue:reset() - self.error = nil self.data = nil + self.error = false self.state = M.FORM_NODATA end @@ -220,13 +216,9 @@ end function AbstractValue:parse(http) self.data = self:formvalue(http) - local ok, err = self:validate() - if not ok then - if type(self.data) ~= "string" or #self.data > 0 then - self:add_error("invalid", err) - else - self:add_error("missing", err) - end + if not self:validate() then + self.error = true + self.state = M.FORM_INVALID return end