# Kirby Fieldtoggle

**URL:** <https://forum.getkirby.com/t/kirby-fieldtoggle/5010>\
**Category:** Plugins\
**Created:** [August 18, 2016, 11:10am UTC](https://forum.getkirby.com/t/kirby-fieldtoggle/5010 "2016-08-18T11:10:30Z")\
**Posts on this page:** 13\
**Page:** 2

<div class="post-metadata">

**Author:** ![thguenther](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/thguenther/32/16708_2.png) [@thguenther](https://forum.getkirby.com/u/thguenther)\
**Post date:** [August 26, 2016, 4:16pm UTC](https://forum.getkirby.com/t/kirby-fieldtoggle/5010/21 "2016-08-26T16:16:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![LCD344](https://avatars.discourse-cdn.com/v4/letter/l/90ced4/32.png) [@LCD344](https://forum.getkirby.com/u/LCD344)\
**Post date:** [August 26, 2016, 7:13pm UTC](https://forum.getkirby.com/t/kirby-fieldtoggle/5010/22 "2016-08-26T19:13:23Z")

</div>

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) - [https://github.com/LCD344/kirby-fieldtoggle](https://github.com/LCD344/kirby-fieldtoggle)

diferences

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.

---

<div class="post-metadata">

**Author:** ![thguenther](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/thguenther/32/16708_2.png) [@thguenther](https://forum.getkirby.com/u/thguenther)\
**Post date:** [September 29, 2016, 9:55pm UTC](https://forum.getkirby.com/t/kirby-fieldtoggle/5010/23 "2016-09-29T21:55:42Z")

</div>

# 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:

[https://github.com/medienbaecker/kirby-fieldtoggle/raw/master/structure.gif](https://github.com/medienbaecker/kirby-fieldtoggle/raw/master/structure.gif)

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.

---

<div class="post-metadata">

**Author:** ![jenstornell](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jenstornell/32/546_2.png) [@jenstornell](https://forum.getkirby.com/u/jenstornell)\
**Post date:** [September 30, 2016, 6:55am UTC](https://forum.getkirby.com/t/kirby-fieldtoggle/5010/24 "2016-09-30T06:55:58Z")

</div>

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. 🙂

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

---

<div class="post-metadata">

**Author:** ![thguenther](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/thguenther/32/16708_2.png) [@thguenther](https://forum.getkirby.com/u/thguenther)\
**Post date:** [September 30, 2016, 7:28am UTC](https://forum.getkirby.com/t/kirby-fieldtoggle/5010/25 "2016-09-30T07:28:52Z")

</div>

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.  

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.

---

<div class="post-metadata">

**Author:** ![webcatsolutions](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/webcatsolutions/32/3473_2.png) [@webcatsolutions](https://forum.getkirby.com/u/webcatsolutions)\
**Post date:** [October 5, 2016, 8:40am UTC](https://forum.getkirby.com/t/kirby-fieldtoggle/5010/26 "2016-10-05T08:40:34Z")

</div>

Hi,

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?

Regards,  
Chantal

---

<div class="post-metadata">

**Author:** ![flokosiol](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/flokosiol/32/468_2.png) [@flokosiol](https://forum.getkirby.com/u/flokosiol)\
**Post date:** [October 5, 2016, 8:44am UTC](https://forum.getkirby.com/t/kirby-fieldtoggle/5010/27 "2016-10-05T08:44:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![webcatsolutions](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/webcatsolutions/32/3473_2.png) [@webcatsolutions](https://forum.getkirby.com/u/webcatsolutions)\
**Post date:** [October 5, 2016, 8:45am UTC](https://forum.getkirby.com/t/kirby-fieldtoggle/5010/28 "2016-10-05T08:45:17Z")

</div>

Thank you flokosiol!

---

<div class="post-metadata">

**Author:** ![kbartos](https://avatars.discourse-cdn.com/v4/letter/k/b9e5f3/32.png) [@kbartos](https://forum.getkirby.com/u/kbartos)\
**Post date:** [March 17, 2017, 1:55pm UTC](https://forum.getkirby.com/t/kirby-fieldtoggle/5010/29 "2017-03-17T13:55:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![thguenther](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/thguenther/32/16708_2.png) [@thguenther](https://forum.getkirby.com/u/thguenther)\
**Post date:** [March 17, 2017, 2:10pm UTC](https://forum.getkirby.com/t/kirby-fieldtoggle/5010/30 "2017-03-17T14:10:25Z")

</div>

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

For example:

```auto
label: Link page
type: fieldtoggle
options:
  nolink: No link
  internal: Internal link
  external: External link
  child: First child page
default: external
show:
  external: extlink
  internal: intlink
hide:
  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.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [March 17, 2017, 2:14pm UTC](https://forum.getkirby.com/t/kirby-fieldtoggle/5010/31 "2017-03-17T14:14:06Z")

</div>

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

```auto
  imagetoggle:
    label: Show image?
    type: fieldtoggle
    default: "no"
    options:
      yes: "Yes"
      no: "No"
    show:
      yes: imagefield
    hide:
      no: imagefield
  imagefield:
    label: Image
    type: image

```

---

<div class="post-metadata">

**Author:** ![kbartos](https://avatars.discourse-cdn.com/v4/letter/k/b9e5f3/32.png) [@kbartos](https://forum.getkirby.com/u/kbartos)\
**Post date:** [March 18, 2017, 1:39pm UTC](https://forum.getkirby.com/t/kirby-fieldtoggle/5010/32 "2017-03-18T13:39:49Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![J.Solano](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@J.Solano](https://forum.getkirby.com/u/J.Solano)\
**Post date:** [September 18, 2017, 3:36pm UTC](https://forum.getkirby.com/t/kirby-fieldtoggle/5010/33 "2017-09-18T15:36:10Z")

</div>

Just great, really appreciated!

[Previous page](https://forum.getkirby.com/t/kirby-fieldtoggle/5010.md?page=1)
