getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.31k stars 168 forks source link

[3.6.0-beta.1] Toggle field error in the panel #3696

Closed mynameisfreedom closed 3 years ago

mynameisfreedom commented 3 years ago

The Toggle field shows an error in the panel in 3.6.0-beta.1

screenshot-localhost-2021 09 22-12_22_49

Localhost, Windows 10

afbora commented 3 years ago

I cannot reproduce the issue. Are you having the same issue with starterkit or demokit? Any plugins installed?

mynameisfreedom commented 3 years ago

Just tested more thoroughly, the error is only in the site.yml Deleted all plugins, the error is still there.

Please, test the toggle field in site.yml

mynameisfreedom commented 3 years ago

Hm, there is no error in the Starterkit.

afbora commented 3 years ago

Still works for me in site.yml.

mynameisfreedom commented 3 years ago

Yes, I tested it too. But my site.yml is still having an error. And it worked ok with 3.6.0-alpha.4

Ok, I will test it further.

afbora commented 3 years ago

Could you post your site.yml please?

mynameisfreedom commented 3 years ago

Here you go, I cleaned unnecessary code

title: Site

tabs:

  # Site Settings tab
  siteoptions:
    label: 
      en: Site Settings
      de: Seiteneinstellungen
    icon: cog
    columns:
      - width: 2/3
        sections:
          sitesetup:
            type: fields
            fields:
          # right nav
          navigation:
            label: Navigation
            type: headline

          # navbar width
          navbarWidth:
            label: 
              en: Navbar width
              de: Navbar Breite
            type: select
            placeholder: Default
            help: 
              en: Default and large has limit, expand has only padding.
              de: Standard und große hat Limit, erweitern Sie hat nur Polsterung.
            options:
              large: 
                en: Large
                de: Große
              expand: 
                en: Expand
                de: Erweitern
            width: 1/3

          menuPosition:
            label: 
              en: Menu position
              de: Menüposition
            type: select
            default: center
            help: 
              en: Align menu center or right.
              de: Menü Mitte oder rechts ausrichten.
            options:
              left: 
                en: Left
                de: Links
              center: 
                en: Center
                de: Mitte
              right: 
                en: Right
                de: Recht
            width: 1/3

          sticky:
            label: 
              en: Sticky navbar
              de: Klebrige Navigationsleiste
            type: select
            options:
              fixed: 
                en: Fixed
                de: Fest
              scroll: 
                en: Show on up
                de: Zeigen Sie auf
            placeholder: "Off"
            width: 1/3

          rightnav:
            label: 
              en: Right side navigation
              de: Navigation auf der rechten Seite
            type: radio
            default: icons
            columns: 2
            help: 
              en: Choose right navigation on desktop option.
              de: Wählen Sie die richtige Navigation auf dem Desktop.
            options:
              icons: 
                en: Icons
                de: Symbole
              button: 
                en: Button
                de: Taste
            width: 2/3

          languagenav:
            label: 
              en: Language nav
              de: Sprachnavigation
            type: toggle
            default: false
            width: 1/3

          searchicon:
            label: 
              en: Search icon
              de: Suchsymbol
            type: toggle
            default: true
            when:
              rightnav: icons
          moreicon:
            label: 
              en: Offset content
              de: Inhalt versetzen
            type: textarea
            when:
              rightnav: icons

          menubuttontext:
            label: 
              en: Menu Button Text
              de: Menüschaltflächentext
            type:  text
            width: 1/2
            when:
              rightnav: button
          menubuttonlink:
            label: 
              en: Menu Button Link
              de: Menüknopf Link
            type: pages
            query: site.pages
            multiple: false
            help: 
              en: Choose a page.
              de: Wählen Sie eine Seite.
            width: 1/2
            when:
              rightnav: button

          mobileNav:
            label: 
              en: Mobile Nav Accordion
              de: Mobile Nav Akkordeon
            type: toggle
            default: false
            help: 
              en: Make mobile navigation behave like accordion when having subpages.
              de: Stellen Sie sicher, dass sich die mobile Navigation wie ein Akkordeon verhält, wenn Sie Unterseiten haben.
            width: 1/3
          mobileNavAnimation:
            label: 
              en: Mobile nav animation
              de: Mobile Navi Animation 
            type: radio
            default: slide
            columns: 3
            help: 
              en: Choose animation for mobile nav canvas.
              de: Wählen Sie eine Animation für die mobile Navi-Leinwand.
            options:
              slide: 
                en: Slide
                de: Rutschen
              push: 
                en: Push
                de: Drücken
              reveal: 
                en: Reveal
                de: Offenbaren
            width: 2/3

  - width: 1/3
    sticky: true
    sections:
      # sections in the last right column

      # a list of files
      files:
        type: files
        headline: 
          en: Files
          de: Dateien
afbora commented 3 years ago

Now I can reproduce the issue. Tracked down and this is about missing text prop for toggle field.

mynameisfreedom commented 3 years ago

Thank you, great.

afbora commented 3 years ago

@lukasbestle @distantnative When null passed to ->toSafeString() method, getting following error:

Kirby\Cms\ModelWithContent::toString(): Return value must be of type string, null returned

$this->id() returns null when model is site:

https://github.com/getkirby/kirby/blob/develop/src/Cms/ModelWithContent.php#L543

distantnative commented 3 years ago

Probably that line should be return $this->id() ?? '';

distantnative commented 3 years ago

The current behaviour for the toggle field on other pages than site is also weird when not passing text: it shows the id of the page next to the toggle. Doesn't make sense to me.

distantnative commented 3 years ago