getgrav / grav-plugin-admin

Grav Admin Plugin
http://getgrav.org
MIT License
355 stars 223 forks source link

Header data causes error on saving #2334

Open flow7 opened 1 year ago

flow7 commented 1 year ago

Hi All, I'm struggling with a form collecting some custom header data and not properly saving it.

Error message on Admin page, after attempting to save: Failed to save entry: Bad form data for field collection 'site': string used instead of an array

Context: Based on the Learn Grav cookbook recipes I'm establishing a private area on my site. I've created a group "Private",

Private:
  access:
    site:
      private: true
  readableName: Private
  description: 'Private User'
  enabled: true

Pages, that are exclusively for this group, then have this in their frontmatter - and it works fine.

access:
    site.private: true

Reproducing the problem Now, for each page created I want to make sure, the editors can choose in the backend, whether the page is Private or not.

I've created a blueprint for the content type:

extends@: default

form:
  fields:
    tabs:
      fields:

        newtab:                        # Create new tab
          type: tab
          title: Custom Settings        
          ordering@: content    # attaching it right to the content tab
          fields:
            privacy:
              type: section
              title: Privacy Settings
              underline: true

              fields:
                header.access.site.private:
                  type: toggle
                  toggleable: true
                  label: Test - access.site.private
                  highlight: 1
                  options:
                    1: PLUGIN_ADMIN.YES
                    0: PLUGIN_ADMIN.NO
                  validate:
                    type: bool

This results in a form, that works fine.

Screenshot 2023-01-23 at 16 37 56

Ticking the box results in this frontmatter entry, which seems fine for me.

---
title: 'Privacy Test 2'
access:
    site:
        private: true
---

Now - anytime I try to save the file again, edits or not, I get shown the error code above and the file is not saved again. Screenshot 2023-01-23 at 10 37 14

Any pointers? Where is my mistake? What am I missing? (Also, is this a Admin Plugin issue? Where would be the right place to ask?)

Super grateful for any help - thanks a lot!!!