|Re: Form Validation and Error Messages [message #1780837 is a reply to message #1780788]
||Mon, 29 January 2018 06:54
| Patrick Bänziger
Registered: September 2011
You can validate single fields in which the user can enter values (AbstractValueField) by overriding execValidateValue.
If you throw a VetoException, the field will appear with a red exclamation mark and the message of the exception will be shown to the user if he clicks on it.
Also, the message will be shown when the whole form is validated (like the fields that are configured mandatory as in your screenshot).
For more complex field validations, you can use the various "...ErrorStatus" methods, that can also supported non-value fields (depending on the field in the end).
For example, you can inform the user about an unknown country code by creating a subclass of IErrorStatus with the severity "warning", and calling addErrorStatus. Note: Only a severity of "Error" will block the form from being saved.
(To remove it - and here comes the relevance of your own subclass - you call removeErrorStatus with the class of your custom error.)
For validation that is not field-based, you can either override execValidateForm on the form itself, or on your handler (if you need several strategies depending on your handler).
Powered by FUDForum
. Page generated in 0.01439 seconds