CheckBoxes Not Appearing in admin Panel

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 -
Screen Shot 2021-04-19 at 10.53.07 AM

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"

Screen Shot 2021-04-19 at 12.45.57 PM

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