getgrav / getgrav/grav-plugin-admin

Header data causes error on saving

Open
#2,334 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
377
Forks
225
Avg merge
11h 51m
Merged PRs (30d)
4

Description

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](https://learn.getgrav.org/16/cookbook/general-recipes#create-a-private-area) 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](https://user-images.githubusercontent.com/5027350/214081641-0e9ed97a-3a74-4302-9f95-0e7be5988bf1.png)

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!!!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.