Closed (fixed)
Project:
Webform Add More
Version:
6.x-1.03
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
22 Feb 2012 at 08:28 UTC
Updated:
13 Sep 2013 at 18:01 UTC
Hi,
I have created 4-5 fieldsets,and all the fields are mandatory. i would like that if user chooses not to add further fieldsets he should be able to submit form and mandatory condition should be ignored in the hidden Fieldsets
Comments
Comment #1
webadpro commentedI'm actually facing the same issue at the moment.
Comment #2
matt bI was thinking of using the webform validation to do some of this...
Comment #3
matt bSo, with the webform validation module installed, you can create additional validations by creating a custom module and implementing hooks from the webform validation module (see the readme.txt in the validation module)
I've created a validator called 'complete set' which lets you select a set of fields (the fields in your fieldset, for example) and validates that either all the fields in the set have been completed, or none of them have.
It's a start, but maybe something needs to be done with a hidden field that could have a value set when the fieldset is displayed. If this hidden field was included in the 'complete set' validation then it would force the fields in the fieldset to be mandatory when the fieldset is displayed.
You need to create a 'complete set' validation rule for each fieldset (for all of the fields in the fieldset).
Comment #4
ongdesign commentedThanks, Matt, this was really helpful. When I added a validation rule using a Date field, I did have to define a slightly different array flattening function to remove the commas, as they were throwing a false positive when a date value was unset. Instead of _webform_validation_flatten_array(), I just used
and the rest of your code worked great.
Comment #5
thentha18 commentedthanks for the code
1 thing though, the error message is shown at the top but the fields are not highlighted
Comment #6
chertzogClosing as custom webform validators can handle this.