Closed (fixed)
Project:
Webform Validation
Version:
7.x-1.1
Component:
Documentation
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
6 Dec 2011 at 16:30 UTC
Updated:
22 Jan 2014 at 22:00 UTC
Jump to comment: Most recent
Comments
Comment #1
stewart.adam commentedI needed to do this too for my module. I ran SELECT queries on the {webform_validation_rule} and {webform_validation_rule_components} tables before/after adding a validator to a test node and then found the code in the module that inserted into said tables. It looks like adding a validator to a web form is handled by the webform_validation_rule_save() function, which takes the its data from add validator form.
If you need to add a handler programatically, add a new line in webform_validation_rule_save():
Then go ahead and add a validator to any web form. After adding the validator you should see the required structure for $values that you can mimic in your module.
Comment #2
attisanhi, I'm looking for exact the some thing too - though I'm a bit shocked there is no "simple" way to accomplish this.
I though it to be something like another entry in the array ...
and to this I would have added my validation rule:
the mentioned way (by stewart.adam) seems to me more a rumpy workaround. (no offense) ...
greets
Comment #3
attisanhi folks,
just in case someone would like to know how to add validation without much investigatory work:
programmatically create your node;
add your webform;
save the node;
prepare the validation;
run webform_validation_rule_save( $validation );
greets
Comment #4
liam morlandIf you write this up nicely, I can add it to the documentation.
Comment #5
liam morlandReferences to functions included in handbook.
Comment #6
liam morlandImproved documentation of webform_validation_rule_save() and webform_dynamic_delete_rule().
http://drupalcode.org/project/webform_validation.git/commitdiff/17127a4