I have a yes/no select component on a form asking if a user is below a certain age. If they mark "yes", then a number of components relating to the users parent/guardian should be required. If it is no, then those components can be left blank.

Comments

BrightBold’s picture

Ooh! Yes. I was just looking to see if anyone was doing this - that's exactly what I'm looking for.

BrightBold’s picture

Oops. Double-submit. Please delete.

svendecabooter’s picture

This kind of functionality will be complex to fit into the architecture of this module...
I'll have to investigate if there's an elegant way of doing this...

If your requirements allow you to spread the form elements over multiple pages, you could easily fix this with Conditional Rules in webform 3.x.
Just add the Yes/No select component on page 1, and on page 2 add some required textfields. Make sure to set the Conditional rules for these textfields (or surrounding fieldset) to only show when the value of the component on page 1 "is one of" "no" / "0" (or whatever the key is for "No" on your Yes/No component).

svendecabooter’s picture

Status: Active » Postponed
BrightBold’s picture

Thanks @svendecabooter, that's a good tip. I'll try that.

bancarddata’s picture

I would be interested in a feature like this in the 7.x branch as well. In my case (and I would use this case on probably every site I ever do), I would like to have a radio button called "Preferred method of contact", with options of "E-mail" and "Phone". Depending on this selection, I would want to make either the "E-mail Address" field or the "Phone number" field required (but not both).

svendecabooter’s picture

That'll not be easy to do.
The #ajax functionality in D7 would allow for this, but it's hard to make this generic.
We would need a UI to attach the #ajax behavior to a selected form element, and then a way to wrap the fields that need to change into a wrapper div or fieldset, so they can be reloaded via AJAX with updated 'required' settings.
Even though i'd like to add that, it'll be a lot of work to make this generic (unless i'm missing an easier approach), and somewhat out of scope of the purpose of this module.

Short term you might be easier off creating a custom module with a hook_form_alter adding the proper #ajax property on the element you want to have trigger the change in behavior, and grouping together the elements that need to be dependent on it.

bancarddata’s picture

Thanks for the explanation. It does indeed sound like much more trouble than it is worth.

Liam Morland’s picture

Issue summary: View changes
Status: Postponed » Closed (outdated)

Drupal 6 is no longer supported. If this issue exists in a later version of webform_validation, please re-open and update the version number.