Netlify-cms: Cannot read property 'slice' of undefined

Created on 7 Jan 2019  路  4Comments  路  Source: netlify/netlify-cms

When trying to create a Collection type that implements the List widget I get the error Cannot read property 'slice' of undefined.

This gets logged into the console.
Editor.js:224 Uncaught (in promise)
{type: "UNPUBLISHED_ENTRY_PERSIST_FAILURE", payload: {鈥, optimist: {鈥, error: TypeError: Cannot read property 'slice' of undefined at a (https://unpkg.com/[email protected]/d鈥
error: TypeError: Cannot read property 'slice' of undefined at a (https://unpkg.com/[email protected]/dist/netlify-cms.js:101:95865)
type: "UNPUBLISHED_ENTRY_PERSIST_FAILURE"

I am using

I am not using Netlify-Cms as an npm package.

To Reproduce

  1. Go to https://wizardly-panini-cda90f.netlify.com/
  2. Create an account
  3. Try to create a General Detail Page
  4. Fill Page info out and hit Save.
  5. Get the error.

Expected behavior
A new page of type General Detail to save.

Screenshots
image

Applicable Versions:

  • Netlify CMS version: 2.3.2
  • Git provider: GitHub
  • OS: Windows 10
  • Browser version chrome 22
  • Node.JS version: 10.11.0

CMS configuration

backend:
  name: git-gateway
  branch: master
publish_mode: editorial_workflow
media_folder: static/img
public_folder: /img
collections:
  - label: "Blog"
    name: "blog"
    folder: "src/ui/folders/posts"
    create: true
    fields:
      - {label: "Layout", name: "layout", widget: "hidden", default: "blog"}
      - {label: "Title", name: "title", widget: "string"}
      - {label: "Description", name: "description", widget: "string"}
      - {label: "Publish Date", name: "date", widget: "datetime"}
      - {label: "Featured Image", name: "image", widget: "image"}
      - {label: "Body", name: "body", widget: "markdown"}


  - label: "General Detail Page"
    name: "generaldetail"
    folder: "src/ui/folders/pages"
    create: true
    fields:
      - {label: "Title", name: "title", widget: "string"}
      - {label: "Layout", name: "layout", widget: "hidden", default: "generaldetail"}
      - {label: "Description", name: "description", widget: "string"}
      - label: "Main Body"
        name: "body"
        widget: "list"
        fields:
          - label: "Carousel"
            name: "carousel"
            widget: object
            fields:
              - {label: Header, name: header, widget: string, default: "Image Gallery"}
              - {label: Template, name: template, widget: string, default: "carousel.html"}

  - label: "Pages"
    name: "pages"
    files:

      - label: "Home Page"
        name: "home"
        file: "src/ui/files/homepage.md"
        fields:
          - {label: "Layout", name: "layout", widget: "hidden", default: "homepage"}

          - label: "Header Section"
            name: "header"
            widget: "object"
            fields:
              - label: "Navigation"
                name: "navigation"
                widget: "list"
                fields:
                  - {label: "Text", name: "linkText", widget: string}
                  - {label: "Link", name: "link", widget: string}
              - {label: Logo, name: logo, widget: image}
              - {label: "Title", name: "title", widget: "string"}

          - label: "Introduction Section"
            name: "intro"
            widget: "object"
            fields:
              - {label: "Tab Name", name: "introTabName", widget: "string"}
              - {label: "Title", name: "introTitle", widget: "string"}
              - {label: "Large Text", name: introLargeText, widget: string}
              - {label: "Description", name: "introDescription", widget: "markdown"}
              - label: "Button"
                name: "introButton"
                widget: "object"
                fields:
                  - {label: "Text", name: "introButtonText", widget: string}
                  - {label: "Link", name: "introButtonLink", widget: string}

Additional context
Repo: https://github.com/meinvolk/gatsby-velocity

Most helpful comment

I believe name: "body" is reserved for markdown content. Try changing the name of the list widget.

All 4 comments

I believe name: "body" is reserved for markdown content. Try changing the name of the list widget.

@meinvolk Here is the issue

- label: "Main Body"
  name: "body"
  widget: "list"
  fields:
    - label: "Carousel"
      name: "carousel"
      widget: object
      fields:
        - {label: Header, name: header, widget: string, default: "Image Gallery"}
        - {label: Template, name: template, widget: string, default: "carousel.html"}

Any widget named body is used as the content of the frontmatter and should return a simple string. So widget like list and object that returns nested values won't work. I suggest you either rename the above widget or use a widget like markdown.

@tomrutgers closing this?

Yes, sorry I am at work and have not been able to test this. I am fairly certain this is going to fix it though. Thanks guys!

Was this page helpful?
0 / 5 - 0 ratings