Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Are there any plans to add support for validating the "Unique values" and "Unique values on multiple fields" options from field_validation module?
Comments
Comment #1
Jelle_SThese validations require calls to the database. This is a bit too heavy to handle with clientside validation and thus we won't support them. See also #1316678: Field validation not working (comment #3)
Comment #2
Jelle_SComment #3
attiks CreditAttribution: attiks commentedIt would be possible if we can easily plugin to their validation rules, but for the moment all validation is done inside field_validation_field_validation_validate($validator_name, $rule, $entity, $langcode, $items, &$errors), the problem is that we cannot send the full entity to javascript so it can be used as a parameter for a js callback. I think you better open a feature request in field_validation issue queue to ask for a function with minimal (simple) parameters so we can integrate with that.
Comment #4
attiks CreditAttribution: attiks commentedComment #5
attiks CreditAttribution: attiks commentedClientside validation supports ajax based validation rules, the only thing that has to be done is to write the code to integrate it, we don't have the time right now, but patches are always welcome.
Comment #6
barraponto CreditAttribution: barraponto commentedUnique values on multiple fields (on the same node) shouldn't require database roundtrips, should it?
Comment #7
barraponto CreditAttribution: barraponto commentedComment #8
Coupon Code Swap CreditAttribution: Coupon Code Swap commentedPerhaps code could be taken from these to implement real-time uniqueness checking:
https://drupal.org/project/formmsgs
https://drupal.org/sandbox/mlncn/1129680
Let me know if this could be sponsored.
Comment #9
barraponto CreditAttribution: barraponto commentedInitial support for unique values. Will trigger errors on non-unique values for a single field.
Included:
:except_value("any value")
. Monkeypatched, will be submitted upstream. Required to avoid validating non-unique "_none" options (happens if user leaves some select widgets unattended)._clientside_validation_set_not_equal
selector building to includeselect
widgets.clientside_validation_field_validation_regular
Lacks:
except_value()
: Support for multiple excluded values.:except_value
support in_clientside_validation_set_not_equal
Comment #10
barraponto CreditAttribution: barraponto commentedComment #11
barraponto CreditAttribution: barraponto commentedAdded rule group support for multiple fields and proper error messages.
Comment #12
jetwodru CreditAttribution: jetwodru commentedno wonder, been trying hard to figure out why the ajax checking on the uniqueness against existing user's email is not working, wishfully implemented soon, Thanks
Comment #13
barraponto CreditAttribution: barraponto commented@jetwong98 my patch is not dealing with that kind of uniqueness (against other entities'fields) but only on uniqueness among different fields of the same entity.
however, I'd be happy to work on such feature as freelance gig. use my contact form if you're interested.
Comment #14
attiks CreditAttribution: attiks commented#11 Is this ready for review?
#12 Can you open a separate issue?
Comment #15
barraponto CreditAttribution: barraponto commented@attiks yes, please review it. Bear in mind that it still lacks:
And, yes, I patched jquery.validate.js. I know I should open a bug upstream, or maybe add an auxiliary jquery file.
Comment #16
FireHawkX CreditAttribution: FireHawkX commented#11 no longer apply to latest version...