Add a custom radio field

I’d like to use a radio component, but give to my user the possibility to add a new category if needed. Is there any way I can do that?

That’s what I tried :

          details:
            label: Infos
            type: structure
            fields:
              category:
                label: Category
                type: radio
                default: false
                options:
                  design: Design
                  architecture: Architecture
                  photography: Photography
                  3d: 3D
                  web: Web
                  free: 
                    type: text
              details:
                label: Détails
                type: text

Thanks!

Yes, you can add a place somewhere in your structure (parent page, site ), where users can define the required options, then query that field in your category field, see Radio | Kirby CMS

So you cannot add to the existing options, but create a field with some defaults that a user can add to.

1 Like

Thanks!

@pixelijn Is it a good idea to create a list field in the same template?

If so, how can I fetch this list and re-use in my radio selection?

Thanks for your help!

The downside of a field in the same page is that the result wouldn’t update unless you save/reload the page, not on the fly.

And no, a list field is not a good idea at all, because you would have to parse the field content first to get the list items.

Use a tags field or a structure field instead.