-
Notifications
You must be signed in to change notification settings - Fork 5
Validation
The result of a validation of an attribute consists of a message and the valid flag. These properties are stored in the meta section (dojo.Stateful) of the attribute.
{
username: {
value: "Will",
state: "Error",
message: "the username is already used by someone else",
}
}
The gform._DecoratorMixin
listens to both properties and displays them appropriately next to the label. The AttributeFactory is responsibe for binding the properties to corresponding properties of the widget if the latter has validation capability. Usually these properties are 'state' and 'message'.
In gform the errors are displayd next to the label. Most Dijits have the ability to display errors themselves. This feature is not used in gform, because not all dijits have the feature and it is not possible to implement it for all. A checkbox's value maybe invalid because it musn't be checked if another attribute in the form has a certain value. This inter-attribute validation would usually be implemented on the server. This might be the reason why the dijit checkbox cannot display an error message. Also the standard dijit error will be displayed when the field has the focus. When transfering the focus to a checkbox via the mouse you will also change its value. Therefore clicking a checkbox to display its error message is not a good idea.