Sign in to edit and +1 items.
Login required
Download

Validation Field

(2)
Author(s) raulinares
Current Release 0.2   (2 years ago)
Grails Version ?
Tags
Dependency
compile ":validation-field:0.2"
Last updated by admin 2 years ago
grails install-plugin validation-field
Last updated by raulinares 2 years ago
Please, take a look in the Screenshots.

Para documentación en español, visite http://latingrails.blogspot.com

Full documentation in http://latingrails.blogspot.com/2010/04/grails-validation-plugin-errorfield.html

The ValidationField plugin is very usefull, it allow us to insert html input and textArea fields in your GSP files, that will show automatocally if the field has any domain validation error (coming soon it will support other html form elements as select tags).

HOW TO START TO USE IT?

  1. INSTALL THE PLUGIN:
grails install-plugin validation-field

2. USE IT:

INCLUDE the <g:validationFieldIncludes /> tag between the <head></head> tags, in your GSP page. (To import the CSS file)

FOR INPUT AND TEXTAREA HTML FORM TAGS

Use the <g:validationField tag='input' type='text' domain="${myObject}" field='theObjectProperty' /> tag to render input form elements that will show any validation error. To render a textArea element use the same tag just like this: <g:validationField tag='textArea' domain="${myObject}" field='theObjectProperty' >

You can use any HTML input property ( id, name, class, style, etc ) in your <g:validationField /> tag

FOR SELECT HTML FORM TAGS

Use the tag:

<validationSelect />

You can use the same properties as in the <g:select /> Grails tag ( http://grails.org/doc/1.1.x/ref/Tags/select.html )

Example:

<validationSelect from="${Country.list()}" domain="${user}" field="country" name="country.id" />

ADVANCED USAGE (other properties):

value:Value by default to be shown.

messageErrorClass: Your CSS class, if you want to overwrite the default plugin CSS class to use in the error/validation message.

fieldErrorClass: Your CSS class, if you want to overwrite the default plugin CSS class to use in the error/validation form field.

customErrorMessage: A custom message to be shown if you don't want to show the grails validation default message.

showMessage: String (true or false) that indicate if you want to show the validation message of just the field with the red border (or style changed).

More info in: http://latingrails.blogspot.com (Documentación en español)

Last updated by admin 2 years ago
Last updated by raulinares 2 years ago
Just using the <g:validationField /> tag, you can render html input forms like this:

Example: <g:validationField tag="input" type="text" domain="${user}" field="name" id="xxx" name="xxx" />

And, when the user send the form, if there are domain validation errors, your form will look like this (Both the CSS class for the message and input form are customizables, and the message itself too )

<g:validationSelect /> tag (Use the same properties as in the <g:select> Grails Tag, aditionally to the ValidationField tags plugin)