Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean header field values in a list #2923

Closed
mloitm opened this issue May 18, 2020 · 3 comments
Closed

Boolean header field values in a list #2923

mloitm opened this issue May 18, 2020 · 3 comments

Comments

@mloitm
Copy link

mloitm commented May 18, 2020

Boolean page fields in lists are saved as '1'/'0' or true/false, depending if the field is in a list or not.

This has changed in 1.7 as 1.6 seems to behave correctly.

Blueprint to reproduce the behaviour:

title: Article
'@extends':
    type: default
    context: blueprints://pages

form:
  fields:
    tabs:
      fields:
        content:
          fields:
            header.boolean_value:
              type: toggle
              label: Toggle
              default: 1
              highlight: true
              options:
                1: 'Yes'
                0: 'No'
              validate:
                type: bool
            header.list:
              name: list_of_booleans
              type: list
              label: List of booleans
              fields:
                .boolean_list_item:
                  type: toggle
                  label: Toggle in a list
                  default: 1
                  highlight: true
                  options:
                    1: 'Yes'
                    0: 'No'
                  validate:
                    type: bool

Saving page in 1.7.0-rc.11 results in the following file content:

---
title: test-article
boolean_value: true
list:
    -
        boolean_list_item: '1' 
---

The same thing in 1.6.25:

---
title: test-article
boolean_value: true
list:
    -
        boolean_list_item: true
---

Environment: Tested in docker with Dockerfile from https://github.com/getgrav/docker-grav.
For 1.7 replaced GRAV_VERSION variable in Dockerfile.

@sojimaxi
Copy link

I notice that as well but the site seems to be working just fine. I actually prefer this because you can have multiple toogled buttons

@mahagr
Copy link
Member

mahagr commented May 22, 2020

The issue also affects old pages (and likely all lists) in Grav 1.7.

@mahagr mahagr transferred this issue from getgrav/grav-plugin-admin May 22, 2020
@mahagr mahagr added the fixed label May 22, 2020
@mahagr
Copy link
Member

mahagr commented May 22, 2020

@mloitm Thank you for reporting the issue! I missed a special case causing some lists to be ignored.

@mahagr mahagr closed this as completed Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants