This is very much a 'wish list' feature, but every now and then I come across a case in which I want a field to be mandatory if another field is in a certain state. The classic example would be the 'Other' text box - a list of options, ending with 'Other', followed by a text box labelled 'If Other, please specify:'. If somebody selects 'other' it would be nice if they were compelled to enter a value in the 'please specify' text box.

(On a side note, the thought occurs that perhaps the option widget could be expanded to offer an 'other' case when required - it does come up a lot, at least for me.)

It's not restricted to option lists, though. Two or three times now I've been asked to create a form that - for example - asks for email, telephone and postal contact details, and finishes up with "How would you prefer to be contacted? [Email/telephone/post]". As above, there's no real way to force people to provide the contact details they've selected as preferred, and forcing everybody to provide all three would be undesirable. We tend to settle for making email compulsory, and saying that if people prefer to be contacted by telephone and don't provide a telephone number then it's their own silly fault.

I'm not sure how you'd go about that in terms of user interface - perhaps offer a collapsible fieldset next to the 'Mandatory' checkbox, which contains a list of all the existing form elements (either in a select box or list of checkboxes) and space to specify the states that would make the current field mandatory.

It's vague and probably complicated, but I thought I would suggest it as a potential future feature in case anybody has the time.

Comments

quicksketch’s picture

Due to the endless number of ways you might want to validate forms we made the "Additional Validation" PHP box. Admittedly it takes some expertise to learn how to use, but you can validate your forms according to any number of crazy criteria.

Reading this issue might help you get a handle on how to use additional validation and submit fields: http://drupal.org/node/81761

quicksketch’s picture

Status: Active » Closed (works as designed)