unimelb / unimelb-design-system

A complete design system for the University of Melbourne
https://web.unimelb.edu.au
30 stars 12 forks source link

Request: Conditional form fields #622

Open woowoowoo opened 8 years ago

woowoowoo commented 8 years ago

Desired behaviour

The simplest example of this is a radio button array, where one of the options is 'other', which then exposes a text area where the user can expand on what 'other' they mean. image image

The conditional content should be able to cope with more complex patterns than just a text area, and the trigger could be any select, checkbox, or radio, control but the behaviour is the same.

I suspect the best way of achieving this would be through a nested fieldset, and some addclass/removeclass functions. It would be REALLY nice if the configuration of triggers and targets could be handled through the Edit+ interface in Matrix, so, please discuss with us before commencing any development.

This is a pre-emptive request, triggered by an enquiry about some forms for Biosciences coming up in a few weeks, but it's a common enough scenario that I think it would be of general benefit, and certainly helpful if we prevent users writing their own ad-hoc js to achieve the same effect.

woowoowoo commented 8 years ago

hmm - I found this: https://codepen.io/memco/pen/BajpD no javascript

waitingallday commented 8 years ago

Ah yeah that's really nice, that's actually how our styled checkboxes work.

axelboc commented 8 years ago

It's really convenient, but it's got major downsides including:

However, you could work around the first point by showing the extra fields by default, and negating the selector: .checkbox:not(:checked) ~ .extra-fields { display: none; }

dcollett commented 7 years ago

+1 on this request.