# Using toggle field in page create dialog

**URL:** <https://forum.getkirby.com/t/using-toggle-field-in-page-create-dialog/32428>\
**Category:** Questions\
**Tags:** v4\
**Created:** [September 8, 2024, 6:31pm UTC](https://forum.getkirby.com/t/using-toggle-field-in-page-create-dialog/32428 "2024-09-08T18:31:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TimKinali](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/timkinali/32/11939_2.png) [@TimKinali](https://forum.getkirby.com/u/TimKinali)\
**Post date:** [September 8, 2024, 6:31pm UTC](https://forum.getkirby.com/t/using-toggle-field-in-page-create-dialog/32428/1 "2024-09-08T18:31:11Z")

</div>

1. Trying to use a toggle field in a page create dialog I get `Field type "toggle" not supported in create dialog`. Consulting the docs, the toggle field is indeed not listed in the supported field types. It seems like a basic field so I was a bit surprised and want to make sure this is correct or I’m missing something obvious?

2. Checkboxes on the other hand _does_ work in the create dialog. But I bumped into another thing that prevents me to use a checkbox. I must use a `when` condition, and the checkboxes field doesn’t support that, it seems?

3. So back to the toggle field: is there any clever workaround to make a toggle field work in the create dialog? If there’s not any reason for it to not be supported, if it’s just an oversight perhaps I could make a field plugin that extends the toggle…? I wanted to give it a try but got stuck on a detal. Docs says this:

> Custom field types are disabled by default. To enable them, add your field type name to:  
> `Kirby\Panel\PageCreateDialog::$fieldTypes[] = 'yourFieldType'`

But I don’t understand where I should add that code?

* * *

Here’s the relevant part of the blueprint (it’s quite a big blueprint so I removed everything I believed was unrelated)

```auto
title: Event
num: zero

create:
  title: "{< page.venue.toVenue.title >} • {{ page.startDate.toDate('EEE yyyy-MM-dd') }}"
  slug: "{{ page.startDate.toDate('yyyy-MM-dd') }}-{{ page.venue.toVenue.city.slug }}-{{ page.venue.toVenue.title.slug }}-{{ page.startTime.toDate('Hmm') }}"
  status: listed
  redirect: false
  fields:
    - startTime
    - endTime
    - timeTBD

columns:
  dateCol:
    width: 7/12
    sections:
      eventDates:
        type: fields
        fields:
  
          timeTBD:
            label: Announce time later?
            type: toggle
            width: 3/12
            text:
              - "no"
              - "yes"
          
         timeTBDInfo:
            type: info
            label: "Door time, start time and endtime"
            width: 9/12
            theme: warning
            text: Time is set to be announced later (TBA)
            when:
              timeTBD: true
              
          doorTime:
            label: Door open time
            type: time
            width: 3/12
            when:
              timeTBD: false

          startTime:
            label: Start time
            type: time
            step: 15
            width: 3/12
            required: true
            when:
              timeTBD: false
          
          endTime:
            label: End time
            type: time
            time: true
            step: 15
            width: 3/12
            when:
              timeTBD: false
          

```

---

<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:** [September 8, 2024, 6:53pm UTC](https://forum.getkirby.com/t/using-toggle-field-in-page-create-dialog/32428/2 "2024-09-08T18:53:04Z")

</div>

> [@TimKinali](#):
>
> Checkboxes on the other hand _does_ work in the create dialog. But I bumped into another thing that prevents me to use a checkbox. I must use a `when` condition, and the checkboxes field doesn’t support that, it seems?

Could you post what you tried?

> [@TimKinali](#):
>
> `Kirby\Panel\PageCreateDialog::$fieldTypes[] = 'yourFieldType'`

This would go into a plugin’s index.php

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [September 8, 2024, 7:10pm UTC](https://forum.getkirby.com/t/using-toggle-field-in-page-create-dialog/32428/3 "2024-09-08T19:10:22Z")

</div>

I do think it’s an oversight that `toggle` isn’t in the default list of supported fields. As far as I know, we only tried to exclude fields that need to open themselves dialogs as Kirby doesn’t support nested/stacked dialogs currently.

---

<div class="post-metadata">

**Author:** ![TimKinali](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/timkinali/32/11939_2.png) [@TimKinali](https://forum.getkirby.com/u/TimKinali)\
**Post date:** [September 8, 2024, 8:02pm UTC](https://forum.getkirby.com/t/using-toggle-field-in-page-create-dialog/32428/4 "2024-09-08T20:02:15Z")

</div>

Hi,  
To investigate I just tried with a custom toggle that just adds itself to the allowed list:

```auto
// toggleExtended/index.js
panel.plugin("tamburlane/toggleExtended", {
    fields: {
        toggleX: {
            extends: "k-toggle-field"
        }
    }
});

```

```auto
<?php
// toggleExtended/index.php
Kirby\Panel\PageCreateDialog::$fieldTypes[] = 'toggleX';
Kirby::plugin('tamburlane/toggleExtended', [
  'fields' => [
    'toggleX' => [
      'extends' => 'toggle',
      'props' => [
      ]
    ]
  ]
]);

```

**Result:**

Test 1: When toggle has no default set (or `default: false`):  
Initially the `when` conditions does not trigger for any fields that has a condition for the toggle. They are not visible at all. But, if I toggle it to true and back to false again, it triggers the conditions so the correct fields are revealed.

Test 2: When toggle is set to `default: true`  
All conditions are working as expected!

So any toggle that is initially off fails to trigger when-conditions until toggled once…

---

<div class="post-metadata">

**Author:** ![TimKinali](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/timkinali/32/11939_2.png) [@TimKinali](https://forum.getkirby.com/u/TimKinali)\
**Post date:** [September 8, 2024, 8:13pm UTC](https://forum.getkirby.com/t/using-toggle-field-in-page-create-dialog/32428/5 "2024-09-08T20:13:38Z")

</div>

> [@texnixe](#):
>
> Could you post what you tried?

Oh yes regarding the checkboxes, I found this thread so I assume it is confirmed it is not expected to work anywhere to use `when` with checkboxes. It doesn’t seem to be about the page create dialog:

> [@Conditionnal field base on Checkboxes option](https://forum.getkirby.com/t/conditionnal-field-base-on-checkboxes-option/16934):
>
> Is it possible (for the moment or in a near-future) to target an option from a Checkboxes field to trigger a conditional logic ? Example: node\_settings: label: Options type: checkboxes options: blank: en: Open in a new window fr: Ouvrir dans une nouvelle fenêtre button: en: Apply the button style fr: Appliquer le style d’un bouton children: en: Include a sub-navigation fr: Inclure une sous-navigation node\_children: label: ... type: ... when: node\_settings: c…

The toggle on the other hand …
