Form Validation and Error Messages [message #1780788] |
Sat, 27 January 2018 09:58 |
|
Hello there,
I was wondering if it's somehow possible to have the default behaviour of form validation changed?
Instead of showing a dialog box with which fields where not entered properly (as shown in the screenshot 1), I'd like to decorate the the affected fields by setting an error state (screenshot 2).
Is this somehow possible to achieve with already available methods (by overriding the appropriate methods)?
Thanks a lot,
Peter
|
|
|
Re: Form Validation and Error Messages [message #1780837 is a reply to message #1780788] |
Mon, 29 January 2018 06:54 |
Patrick Baenziger Messages: 96 Registered: September 2011 |
Member |
|
|
Hello Peter
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).
Regards,
Patrick
|
|
|
Powered by
FUDForum. Page generated in 0.02415 seconds