Open woowoowoo opened 8 years ago
hmm - I found this: https://codepen.io/memco/pen/BajpD no javascript
Ah yeah that's really nice, that's actually how our styled checkboxes work.
It's really convenient, but it's got major downsides including:
:checked
pseudo-class and general sibling selector ~
)hidden
, aria-expanded
) and may also require smart focus managementHowever, 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; }
+1 on this request.
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.
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.