Toggle Causing Error in Panel?

panelfield
panel

#1

Hi there, I am building a site and was testing out a toggle feature in a blueprint & in the panel – however it seems to have thrown an error in the cms?

The error I get is:

Missing argument 1 for Kirby\Panel\Models\Page::toggle(), called in […]/site/panel/app/src/panel/models/page/changes.php on line 71 and defined

I have since removed the toggle field from my blueprint however it is still throwing the error? I don’t really know how this is possible or how to fix it :sweat:

My current blueprint is:

title: Full Text

icon: text-width

pages: false
files: false

options:
  template: false
  url: false
  preview: false

fields:
  title:
    label: Title
    required: true
    type: text

  text:
    label: Text
    required: true
    type: textarea
    required: true
    icon: align-left

And the toggle aspect I added which broke the panel page was:

  toggle:
    label: Invert colours?
    type: toggle
    text: yes/no

I am running Kirby 2.4.1


#2

This is an issue with the field name. If you rename “toggle” to something like “myToggle” or “isInverted” or whatever, it will work.


#3

You should also update Kirby and the Panel. This does not solve your problem, but the version should always be up to date.
Today it is 2.5.12.


#4

Thanks so much @texnixe – is this just a problem with the toggle feature? Or should I steer clear from naming fields by their type on the whole?


#5

As far as I’m aware, the problem in the Panel is particularly an issue with the toggle field.

However, it makes sense to use field names that are not used as native Kirby page methods, because they will conflict, see the docs:

https://getkirby.com/docs/panel/blueprints/form-fields#field-names


#6

Just ran into this issue myself. Might want to update the documentation so the example doesn’t suggest using “toggle” as the field name. :slight_smile:


#7

Yes, done (and some more chars)