New issue 12 by keso...@gmail.com: Unique validation don't work for update
http://code.google.com/p/jquery-validation-ui-plugin/issues/detail?id=12
What steps will reproduce the problem?
1. Create a domain class and add it a property with an "unique" constraint
2. In edit.gsp add the <jqvalui:renderValidationScript /> tag
3. Try to submit the form
What is the expected output? What do you see instead?
The succerful submit. Instead, after the unique field appear the error
message message related to not uniqueness of field.
What version of the product are you using? On what operating system?
Grails 1.3.7
jquery-validation-ui-plugin 1.2.1
Please provide any additional information below.
if was applied an "unique" constraint on a domain class,
jquery-validation-ui-plugin generate a "remote" client-side validation.
This work fine for create fase, but not for edit one, because actually it
do not pass to controller the id of the edited instance.
I've attached controller and taglib with some little modification for fix
the problem. The trick rely on convention that in edit.gsp form the id of
instance was an <input type="hidden" id="id" name="id" />.
Attachments:
JQueryRemoteValidatorController.groovy 2.5 KB
JQueryValidationUiTagLib.groovy 31.0 KB
Thanks for reporting the issue. I not sure I am understand the issue well.
Great that you can fix it yourself and submit the fix. By the way, if you
don't need client validation for specific property, you can specified it
in "not" attribute of the <jqvalui:renderValidationScript /> tag, you can
find out more here
http://code.google.com/p/jquery-validation-ui-plugin/#Tags
Hi,
sorry for my unclear explanation.
The problem is: if you apply an "unique" constraint on your domain class,
jquery-validation-ui plugin generate correctly client-side rule of
type "remote" (AJAX call to JQueryRemoteValidator/validate action). But, if
you use such approach for an edit form, you need to communicate to the
JQueryRemoteValidator/validate action the ID of entity that you are
editing, otherwise the unique validation always fails.
Take a look at attached JQueryRemoteValidatorController.groovy for see what
I'm talking about.
Instead, in JQueryValidationUiTagLib.groovy (at row 423) you can see the
trick I used for pass the ID to the JQueryRemoteValidatorController.
Thanks for further explanation. I understand better now. I will look into
it.
Hi, no interest in this fix? We are really constrained to fork the plugin
for use it in our projects? :(
Comment #5 on issue 12 by limchee...@vobject.com: Unique validation don't
Sorry for long delay, I will look into it over this weekend.
Comment #6 on issue 12 by limchee...@vobject.com: Unique validation don't
Incorporated your code to 1.2.2 released with minor changes: rename the
currentId to id. Please verify.
Work well!
Many thanks for your great job!
Gennaro
Comment #8 on issue 12 by limchee...@vobject.com: Unique validation don't
Hi Gennaro,
You're welcome and thanks for verification.