getgrav / getgrav/grav-plugin-admin

Pages field - Saving sets the value to first in list if not set manually

Open
#1,337 1 comment 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
PHP
Stars
377
Forks
225
Avg merge
11h 51m
Merged PRs (30d)
4

Description

Hi
I'm using a Pages field to set a url for an optional call to action button in some pages, this works fine.
However when the field is not used and the page is saved then the Pages field is automatically saved to the first option in the (happens to be the homepage) even though I didn't choose anything.
I can delete the values from the frontmatter manually the next content update save will bring them back again.

The steps to reproduce:
1. Add a Pages field to a blueprint and confirm it is displayed in the admin panel
2. Switch to Expert mode and inspect the front matter - no Page field
2. Update / fill in another other field on the page in the admin panel except for the Page field, press Save
3. Switch to Expert mode and inspect the frontmatter - the Page field will now have a value

My blueprint is straightforward:
```
.url:
type: pages
size: medium
label: 'Choose a page'
show_all: false
show_modular: true
show_root: false
```
I have tried adding a blank `default: ''` value to the above code but this just gets ignored as its not a valid page.

The front matter result
` url: /home`

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.