Closed (fixed)
Project:
Webform Validation
Version:
7.x-1.x-dev
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Anonymous (not verified)
Created:
25 Sep 2011 at 11:33 UTC
Updated:
25 Dec 2019 at 17:56 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
jfrederick commentedSee attached patch.
This patch adds a weight to validation rules. It replaces the validation rules admin interface with a form and a corresponding theme function, which formats the form as a drag and drop table.
When the validators are run, they are run in the order of their weight, as set in the drag and drop table. If you do not re-order the validators, their default weights are 0. If validation weights are equal, they are run in the order of ruleid DESC, just as they were in the past.
My main use case for this is to have conditional validation. I have one validator that I want to only run if all other validation has passed. Now, by placing this validator last, and checking form_get_errors(), I should be able to do this. Relates to How to create a conditional/dependent validator which is only triggered when all others validate
Disclaimer: The patch includes a schema update that adds a 'weight' field to the webform_validation_rule table. To run the schema update, run update.php or drush updb. Naturally, this update hook (7002) may interfere with the sequence of update hooks that may be introduced in the module henceforth. I still felt it best to move forward with more regular update hook numbering.
Please help fix up any mistakes in the patch, thanks!!
Comment #2
liam morlandThanks for the patch. I will review it when I have time. If others can give it a try, that would be appreciated.
Comment #3
liam morlandThanks very much for the patch. I think this is a good feature to have. A few comments:
Thanks again.
Comment #4
jfrederick commentedThanks for the suggestions, they were extremely helpful.
Attached is an updated patch. It fixes 4 out of 5 of the issues you raised, simply excluding the separation of the patch into two separate patches. The reason that is problematic is the conversion of the admin interface to a theme function is heavily tied to displaying the admin interface as a form. But without the new weight field, there is no reason to have the admin interface be a form; there would be nothing to submit.
But let me know what you think.
Comment #5
jfrederick commentedHeh, I included a stray dpm() in that patch. Removed in attachment.
Comment #6
liam morlandThanks very much.
http://drupalcode.org/project/webform_validation.git/commitdiff/5245ebd
http://drupalcode.org/project/webform_validation.git/commitdiff/df9eab9
Comment #7
liam morlandComment #8
liam morlandDrupal 6 is no longer supported.