Blueprints checkboxes bug: won't save an empty list

I may have found a bug with new user blueprints in Kirby 2.2.x panel.

The issue occurs when using checkboxes on a user blueprint. I originally found the issue when using a checkboxes field with query fetching another page’s children. But I’ve replicated it with a fresh, clean install of plainkit. And the bug still shows up even with static options.

The issue:

It will not save an empty list.

  • It saves properly if all items are checked
  • It saves properly if at least one item is checked
  • But it won’t save properly if all items are unchecked

PHP version: 5.6.15

Panel version: panel @ 53ebd4b

Kirby version: kirby @ b45f01b

To replicate:

// site/blueprints/users/admin.yml
fields:
  checks:
    label: Checks Test
    type: checkboxes
    # setting an empty default has no effect
    # default: 
    # default: ""
    options:
      one: One
      two: Two
      three: Three

Then visit /panel/users/[you] and check one, save. Then uncheck it, and save. You’ll see it’s still checked. Try multiple combinations, still occurs.

I’ll try to dig through the source and see if I can find the responsible code, will submit a PR if I can find it.

To be sure, I also checked if this occurs on regular pages, and the issue still occurs.

So it’s not a bug specific to user blueprints.

// site/blueprints/default.php
fields:
  categories:
    label: Categories
    type: checkboxes
    options:
      design: Design
      architecture: Architecture
      photography: Photography
      3d: 3D
      web: Web
  • Same issue as before: Won’t save an empty list.
  • Occurs on both .yml and .php blueprints.

Possibly related:

I created an issue on GitHub: https://github.com/getkirby/panel/issues/684

Thanks @texnixe for creating the issue.

For future reference, 2.2.1 works fine for checkboxes on regular pages, but checkboxes on user blueprints suffer from the same incorrect behavior.