Storing multiselect field from controller

I am moving a site from kirby2 to kirby3 and I am having trouble with a multiselect field.

Existing data is stored as a comma separated list:


the blueprint has this for that field:

    label: Categories
    type: multiselect
    search: true
    options: query
    translate: false
      page: categories
      flip: true
      fetch: pages
      template: category
      value: '{{id}}'
      text: '{{id}}'

Reading the existing data from the database works as expected but updating the field doesn’t.

In kirby2 we sent a comma separated list to the page’s update function but if I do that in kirby3 the writeContent function receives NULL.
I assume there is a check somewhere along the way that finds the format invalid. What would be the correct data to send to the update function?

I said everything works as expected however although this is true for my controller, which expects a comma separated list, it is not true for the panel. That complains of:

Access to non-existing property pages on array in file: /home/tick/Projects/athleticskillsplatform/kirby/src/Toolkit/Query.php line: 242

So apparently I have to read up on multiselect because that seems to have changed considerably.

Those query settings are not valid.

A multiselect field still stores data as comma separated list. Would be more useful to see your code.

All I do is this:

    foreach ($filterHash as $hash) {
      if ($category = $site->index()->findBy('hash', $hash)) {
        $filters[] = $category->id();

    $video['category'] = implode(',', $filters);

$page = $page->update($video, kirby()->language()->code());

The $video[‘category’] has the correct values but when it gets to writeContent the $data array has no value for category. So apparently it gets thrown out because of the bad configuration for the field.

I will try to fix that first.

I think your multiselect should be defined like this:

      label: Categories
      type: multiselect
      search: true
      options: query
      translate: false
        fetch: page('categories').grandchildren.listed
        text: "{{ }}"
        value: "{{ }}"

Sadly that gives me this:

Error in "category" field.
Cannot access array element page with arguments in file: kirby/src/Toolkit/Query.php line: 104


        fetch: site.find('categories').grandchildren.listed

Yes, that fixed both the panel and the frontend.

Apparently there is something checking the field data when it gets updated. I had a similar problem with date fields where apparently the old datetime format didn’t get through the validation.

Thank you for the help.

Yes, Kirby validates your blueprint settings.

Is there a way to get errors from that process when updating from a frontend controller?

If you set the third parameter ($validate) to true, you should get an error when the page to update is not a draft (in case of draft status pages, no validation takes place).

The wrap your call in a try/catch block to catch errors.

So if $validate is set to false there is no error but the value just gets discarded?

Hm, that doesn’t seem to have the desired effect.

I have created a bug report: