Closed idgserpro closed 8 years ago
This is the way invariants are designed, see
In an invariant simply do not raise an exception which does not inherit zope.interface.Invalid
.
BTW WidgetActionExecutionError
is an exception internally used by z3c.form
. I could not see a reason why you should use it in your validation code.
@icemac I want to validate a field that depends on another field. But I want the error message to be shown in that particular field and not on top of form.
My code is based on: http://docs.plone.org/develop/addons/schema-driven-forms/customising-form-behaviour/validation.html#validating-in-action-handlers
@icemac maybe I should raise an WidgetActionExecutionError in handler of button, as shown in the code indicated, instead raise in the invariant. Is this?
@idgserpro If you want to display the error message on a specific field you have to follow the approach shown on docs.plone.org validating in the action handler. I am currently not aware how this would be possible using interface invariants.
@icemac Thank you!
@icemac maybe this:
In an invariant simply do not raise an exception which does not inherit zope.interface.Invalid.
should be documented somewhere.
When I have an invariant that launches a WidgetActionExecutionError, this exception is not catch and is show in the log:
This is because the method validateObject only catch exceptions of type zope.interface.Invalid and WidgetActionExecutionError doesn't inherit from zope.interface.Invalid.