Active
Project:
Field Validation
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
5 Oct 2012 at 20:27 UTC
Updated:
6 Nov 2012 at 14:59 UTC
I'm currently writing regex rules to validate a field and I want to display a different error message depending on what the user did wrong, so I'm creating multiple regex rules. However currently the way this module works is it matches one rule at a time and displays that error message, it'd be great if it could match multiple rules at once and display all the error messages so the user doesn't fix the one error message they receive, submit the form and then get another error message for the same field.
Comments
Comment #1
g089h515r806 commentedYou could use php validator to solve this issue.
Comment #2
SeanBannister commentedAwesome, for sure.
Decided to do it the proper way in a module, read the guide at http://drupal.org/node/1553646
And just to start out I put this code into a custom module (haven't got the domain validation working yet). But its not showing up as a new rule in the interface. I know I'm doing something obviously wrong here, was just wondering if you could point me in the right direction.
Comment #3
g089h515r806 commentedJust copy a validator, rename it, change the logic of validate.
if you want to put it into a custom module, you need implement hook_ctools_plugin_directory:
Then you could put your validator file at the firectory that you specified.
Comment #4
SeanBannister commentedThanks so much for your help, I started to work on this and almost got it working however then I realised I would also need to write integration with Clientside Validation and was a little stuck on time so just simplified my validation rule into one.
I do however think this would be really handy having the ability to output the result of multiple rules at once. Not only because then I wouldn't have to write Clientside Validation as well :)
I've also filled an issue at http://drupal.org/node/1804924 as Clientside Validation has a bug dealing with multiple validation rules at once.
Comment #5
g089h515r806 commentedWe set several error messages to one form element, but Drupal only display the first(or last) one.