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)
I was made aware of a bug when submitting the form while the element is
disabled based on it's dependencies
The fix was to inherit from AbstractValue instead of just node
AbstractValue's AbstractValue:resolve_node_depends() in particular
solves the issue, but it made more sense to just use the full base class
This add support for a write() method on sections, in addition to the
value and form level write(). write() is only called when the section is
valid and visible. In addition, write() is empty by default, so it can be
overridden more easily.
With 11a3b56617 ("gluon-web-model: add dependency support for
sections"), a "reset" function was added to all model nodes. This
conflicts with the "reset" field of the Form object, making reset
buttons show labels like "function: 0xbb8d50" and possibly breaking form
processing when packages override the reset field.
Validation errors are mostly handled in the frontend (by displaying
invalid fields with a red background). There was some code left in the
backend for handling different kinds of errors, and returning custom
error messages from validate(), but the resulting value was not used
anywhere.
- Add a dependency array to section template
- Lift dependency handling from AbstractValue to Node
- Split resolve_depends() into a function handling dependencies of a
node itself (resolve_node_depends()), which now is used for all nodes,
and the existing recursive descent through the node tree
- When any node's dependencies are not satisfied, all descendents are
reset recursively, meaning that an option in a section that is hidden
will always be ignored, as if the option's own dependencies were
unsatisfied
Fixes: #1349