Kirby Fieldtoggle

Thanks a lot @LCD344! I updated the JavaScript file to use non global variables and convert the field names to lowercase.

No problem this is what we got the community for!

anyway, I forked your plugin (for my own use - but of course its open source) -


  1. The style now looks like a switch.
  2. It’s based on a checkbox and not togglefield (because I had the switch already done for the checkbox
  3. It’s registered through the plugins directory and not fields (personal preference - trying to keep all non original kirby files in the same place)
  4. It’s installable using the kirby cli.

Fieldtoggle v2

The Fieldtoggle field just got a lot more powerful. You can now define as many options as you want. Previously you could only use the “Yes/No” and “True/False” options. This makes it possible to do something like that:

Since the syntax had to change obviously, I updated the original post, too.

TL;DR: You now add the options in show or hide and list the affected fields.


I will probably try it out in the future. Until then I have a few questions about it.

  1. What happends to the fields that are not shown, are they still saved to the content text file?
  2. Is it possible to have “nesting” hidden parts? Let’s say I want to add a category choice inside a category choice.
  3. Is it possible to use checkboxes, like match two of them to show the section? or match a specific checkbox.
  4. Is it possible to have an input text field like match while type feature?

I guess most of the above does not work with the current version but your field seems still very powerful. :slight_smile:

Feel free to add what you want from the list as issues to your repo if you like any of the ideas.

  1. The hidden fields are still there, just not visible. They are also required, since you can’t overwrite the validation.

  2. Nesting is possible, I just pushed the necessary commit for that.

    Overall it’s important to do something with the value of the fieldtoggle field. It is a normal radio button after all. So in your template you’d still need a condition to check what option was selected. That way it’s not important what the hidden fields store.

  3. After I wanted to switch from the toggle field, I initially used the checkbox. Fo my use cases this just made it way more complicated. What do you want to use it for?

  4. I see the appeal of an instant filter, but I think that would be an entirely different field.



I’m new to Kirby and think I will need this fieldtoggle plugin for a project. In the install docs it mentions to add everything to the ‘site/fields’ folder. The thing is, I’m using the Kirby starterkit and it does not have a fields folder… Does the plugin require something to be installed that is not in the starter kit or are the install docs incorrect and should I put it in the site/plugins folder?


Simply create a site/fields folder, if it doesn’t already exists.


Thank you flokosiol!

Hi, is there a way to set a default value?

Yes, you can simply set default: to whatever option should be selected by default.

For example:

label:         Link page
type:          fieldtoggle
  nolink:      No link
  internal:    Internal link
  external:    External link
  child:       First child page
default:       external
  external:    extlink
  internal:    intlink
  nolink:      intlink extlink
  external:    intlink
  internal:    extlink
  child:       intlink extlink

This would set the option external as default and make the field extlink visible by default. Remember to remove any existing content in the content files to simulate a newly created page and test the default value.

Note that when you have “yes/no” options, you have to wrap the default option in quotes:

    label:       Show image?
    type:        fieldtoggle
    default: "no"
      yes: "Yes"
      no: "No"
      yes: imagefield
      no: imagefield
    label: Image
    type:  image

When I copy paste your code it works great… I wasn’t sure if default should work, I didn’t found it in examples and it didn’t work with my values (I tried before). But after I started from scratch it is now OK, so there was something wrong with my blueprint, maybe just a stupid typo… Thanks a lot!

Just great, really appreciated!