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

Fields with widget: hidden and default value does not work with collections containing files property #5806

Closed
andreasbalevik opened this issue Sep 13, 2021 · 1 comment
Labels
duplicate type: bug code to address defects in shipped code

Comments

@andreasbalevik
Copy link

andreasbalevik commented Sep 13, 2021

Describe the bug
Im using Netlify CMS with jekyll.

I got this problem.

A collection with files, using the widget hidden with a default value does not get populated.

  - label: "Pages [NO]"
    name: "pages_no"
    files:
      - label: "Frontpage"
        name: "frontpage_no"
        file: "_nb/pages/frontpage.md"
        fields:
          - {label: Layout, name: layout, widget: hidden, default: index }
          - {label: Language, name: language, widget: hidden, default: nb }
          - {label: Page Title, name: page_title, widget: string}

Outputs

frontpage.md

---
page_title: Test 123
---

But using a collections with folder.

- label: "Pages [folder]"
   create: true
   folder: "_folder"
   name: "page_folder"
   fields:
     - {label: Layout, name: layout, widget: hidden, default: index }
     - {label: Language, name: language, widget: hidden, default: en }
     - {label: Page Title, name: page_title, widget: string}

Outputs correct
{{slug}}.md

---
layout: index
language: en
page_title: Test 123
---

To Reproduce

Site with netlify cms. Use _config provided below.

Expected behavior

  - label: "Pages [NO]"
    name: "pages_no"
    files:
      - label: "Frontpage"
        name: "frontpage_no"
        file: "_nb/pages/frontpage.md"
        fields:
          - {label: Layout, name: layout, widget: hidden, default: index }
          - {label: Language, name: language, widget: hidden, default: nb }
          - {label: Page Title, name: page_title, widget: string}

should produce a the file
frontpage.md with the following content

---
layout: index  
language: nb 
page_title: Test 123
---

Applicable Versions:

netlify-cms-app 2.15.42
netlify-cms-core 2.49.0
netlify-cms 2.10.162

Github

CMS configuration

---
backend: 
  branch: main
  name: git-gateway

collections:

  # THIS DOES NOT WORK
  - label: "Pages [NO]"
    name: "pages_no"
    files:
      - label: "Frontpage"
        name: "frontpage_no"
        file: "_nb/pages/frontpage.md"
        fields:

          # DEFAULT VALUE DOES NOT WORK
          - {label: Layout, name: layout, widget: hidden, default: index }
          - {label: Language, name: language, widget: hidden, default: nb }
          - {label: Page Title, name: page_title, widget: string}

  # THIS DOES NOT WORK
  - label: "Pages [EN]"
    name: "pages_en"
    files:
      - label: "Frontpage"
        name: "frontpage_en"
        file: "_en/pages/frontpage.json"
        fields:

          # DEFAULT VALUE DOES NOT WORK
          - {label: Layout, name: layout, widget: hidden, default: index }
          - {label: Language, name: language, widget: hidden, default: en }
          - {label: Page Title, name: page_title, widget: string}

  # THIS WORKSS
  - label: "Pages [folder]"
    create: true
    folder: "_folder"
    name: "page_folder"
    fields:
      - {label: Layout, name: layout, widget: hidden, default: index }
      - {label: Language, name: language, widget: hidden, default: en }
      - {label: Page Title, name: page_title, widget: string}

media_folder: static/images/uploads
@andreasbalevik andreasbalevik added the type: bug code to address defects in shipped code label Sep 13, 2021
@erezrokah
Copy link
Contributor

Closing this in favor of #3046, thank @andreasbalevik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

2 participants