Vaadin add custom validator and content mode

110 Views Asked by At

There are some fields to validate. Field's captions contains formatting like ", ", etc with the option captionAsHtml="true". When using someField.addValidator(..., errorString), the error message shows errorString and the field name in brackets(parenthesis) and it looks like that is not cool. Is there any way to show the field name in the validation error message with formatting. Tried to use Notifications instead, but they used in beforeFormSaved and showed when the form is closed unlike using validators.

1

There are 1 best solutions below

0
On

You did not share your code, but are you trying it this way?

    TextField field = new TextField("<i>Caption</i>");
    field.setCaptionAsHtml(true);
    UserError componentError = new UserError("<b>Error</b>", ContentMode.HTML,
            ErrorLevel.ERROR);
    field.setComponentError(componentError);