Hey, Iām trying to allow click-thruās to be edited by the admin in panel, however if using a toggle, checkbox, or radio buttons, the actual box itself is not appearing in the panel. Hereās my code in the yaml.
fields:
title:
label: Name
type: text
role:
label: Role
type: text
clickthru:
label: Click Through
type: checkboxes
default: turn on
required: true
width: 1/2
min: 1
max: 1
options:
turnon: Turn On
turnoff: Turn Off
Screenshot of the result -
Any suggestions?? Currently working in 2.5.8
You default value is misspelled and min/max are not valid options of the checkboxes field (havenāt used Kirby 2 in quite a while)
Ah, and options are not properly indented
Thanks for your response! So should it read like this? Itās still not rendering in the panel.
clickthru:
label: Click Through
type: checkboxes
default: turnon
required: true
options:
turnon: Turn On
turnoff: Turn Off
clickthru:
label: Click Through
type: checkboxes
default: turnon
required: true
options:
turnon: Turn On
turnoff: Turn Off
Nope:
clickthru:
label: Click Through
type: checkboxes
default: turnon
required: true
options:
turnon: Turn On
turnoff: Turn Off
Thank you! Now I need to work on the functionality, and allow the admin to only select one or the other, so I may switch it to toggle. Weāll see.
@pixelijn - Toggle wasnāt populating for me so do you now how to limit the checkboxes to 1 selection?
A checkboxes field is not the right choice for selecting one out of multiple options, Either use a toggle field or radio buttons.
A toggle field is not populated with options, it takes some text input and values yes/no on/off, see the documentation.
1 Like
So the toggle is not populating for me, in the same way as the checkbox was earlier? Iām not sure whatās wrong with it?
toggle:
label: Allow Click Through
type: toggle
text:
- "no"
- "yes"
field.php
// lowercase the type
$params[ātypeā] = strtolower($params[ātypeā]);
See docs for correct field setup: Toggle | Kirby
Iāve been studying these and Iām not sure what Iām missing.
To me it seems that you are following the Kirby 3 docs instead of the Kirby 2 docs
Is this a new project? Kirby 2 is no longer supported and you shouldnāt be using it for new projects.
I was asked to update a friends site, and I donāt want to update to 3 if that means a lot will break. Itās very minimal, Iām just trying to get rid of click-thruās for their staff.
Yeah, thatās totally fine. But please try the toggle field syntax in the link above.
That works, so I would use toBool in the if statement correct? Iām not getting the functionality I want in using this.
<?php if ($item->featured()->toBool()->): ?>
Again, there is no toBool()
method in Kirby 2, thatās Kirby 3 again. Itās either bool()
or isTrue()
. Please make sure to follow the right documentation for Kirby 2.
1 Like