Panel: reveal following fields if toggle "Yes"

I want to show some field in the panel only if a particular radio button is selected.

My blueprint would look like:

brand:
    label: Brand
    type:  tags
different_manufacturer:
    label: Is this tube produced by a different manufacturer?
    type: toggle
    default: no
    text: yes/no
manufacturer:
    label: Real Manufacturer
    type:tags

I would like the field “manufacturer” to be displayed only if the user select the toggle Yes.

Is something like this achievable?

Unfortunately, not out of the box. Maybe with a custom field. As far as I remember, someone once tried it but I’ve never seen it done. There was an issue on GitHub regarding this topic quite a while ago.


Hmm maybe this works, create a new custom field, simple one toggler, and if it´s active display fields attached in the field array(fields). Something like this should work :

toggler:
    label: Style
    type: toggler
    fields: color, padding, font, margin

and js

if (toggler checked)
  each fields
      display block
else
  each fields
      display none

and php

if (toggler)
     echo the style
else
    no I will not !!

@texnixe can this work ?
I´m not seriously experienced on doing custom fields, but if you think it might work I will have a go :grimacing: !!

I’m not very experienced with custom fields myself, but since people here have built very powerful ones, I think something like that should work perfectly fine. And it would be really great to have such a field as long as it is not part of the core yet (like it should be :stuck_out_tongue_winking_eye:).

1 Like