-
New Feature
-
Resolution: Fixed
-
Normal
-
None
Problem Statement
At the moment you can have a validator on a form, for example:
<groupbox form="@id('event') @validator('org.zkoss.todo.event.EventValidator')">
However, when you do this there is no way to retrieve messages individually, so if you have a form you cannot place errors next to the respective component. This is the most common use case on forms, so in my opinion is essential.
Possible solution
When adding the invalid message like this this.addInvalidMessage(ctx, "age must be over 1"); we have an additional argument for the key:
this.addInvalidMessage(ctx, "key", "message");
We can then therefore retrieve the error message next to our respective component, for example say we want to validate the age in an intbox.
this.addInvalidMessage(ctx, "age", "age must be > 1");
Then in the zul file:
<textbox id="txtAge" value="0" /> <label value="@load(frm.validationmessage['age'])" visible="@load(not empty frm.validationmessages['age'])" />