Closed (fixed)
Project:
Webform Validation
Version:
7.x-1.x-dev
Component:
Validation rules
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
24 Apr 2012 at 20:57 UTC
Updated:
1 Oct 2014 at 18:12 UTC
Jump to comment: Most recent
Comments
Comment #1
chertzogI needed this for a project, wasnt to hard to write.
Comment #2
steve_lou commentedIt works for me,but by the way ,can I set one of the items equals the sum of the others items? such as Area 4=Area 1+Area 2+Area 3
I need $rule['data'] to be the value of Area4.
thank you very much, chertzog .
Comment #3
chertzogWhat you could do is change the "custom_data" parameters to accept the "field_key" of "Area 4". Then use that form key to find the value of the "Area 4" and do your comparisons that way.
Comment #4
liam morlandPlease provide the code as a patch to the latest development version for inclusion.
Comment #5
Rubinja commentedCan anyone help me out on how to use this code?
Where do I need to copy/paste it?
Thanks in advance!
Ruben
Comment #6
liam morlandThe code would need to go in a custom module. In the example above, the name of the custom module is "mymodule".
Comment #8
liam morlandComment #10
TheWrench commentedThank you for this amazing custom module, chertzog. Did exactly what I needed it to!
Comment #11
jbova commentedIn reply to steve_lou, and credit to the idea from chertzhog, here is a working example:
For this example, you would need to select all fields which should be summed AND the field you are comparing against when setting up the validation rule. For the custom data, you enter the field key. This field is excluded from the sum, and then compared to the sum of the other fields.