-
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? -
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? -
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)
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