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