gluon-web-model: fix issue with warning blocking save on private-wifi

The other bugfix which made this element inherit from AbstractValue
caused AbstractValue:validate() to be inherited aswell

Now added an if so validate only runs if a datatype is set
(since Element is meant as a generic way to extend web-model without
modifying web-model - also to add custom inputs - just hiding it behind an if sounds like a sane solution)
This commit is contained in:
Maciej Krüger 2023-01-28 20:34:52 +01:00
parent 03fe3d4a1d
commit 1f451d4021
No known key found for this signature in database
GPG Key ID: 0D948CE19CF49C5F

View File

@ -429,6 +429,23 @@ function Element:__init__(template, kv, ...)
self.error = false
end
function Element:parse(http)
if not self.datatype then
self.state = M.FORM_VALID
return
end
return AbstractValue:parse(http)
end
function Element:validate()
if not self.datatype then
return true
end
AbstractValue:validate()
end
local Section = class(Node)
M.Section = Section