- Do you want to request a feature or report a bug?
Bug
- What is the current behavior?
Entering a relation comes up with TypeError: Cannot read property 'isValid' of undefined. No autocomplete is available for the relation either.
- If the current behavior is a bug, please provide the steps to reproduce.
I enter a category when creating a blog post and get an error. I set up categories as a collection with json files.
- What is the expected behavior?
Perhaps I set up my config.yml incorrectly? I would expect there to be no error
- Please mention your versions where applicable.
Netlify CMS version:
Browser version: 1.9.3
Node.JS version: 10.3.0
Operating System: MacOS
- Please link or paste your config.yml
below if applicable.
backend:
name: git-gateway
accept_roles: #optional - accepts all users if left out
- admin
- editor
media_folder: "static/images/uploads" # Media files will be stored in the repo under static/images/uploads
public_folder: "/images/uploads" # The src attribute for uploaded media will begin with /images/uploads
collections:
- name: "blog" # Used in routes, e.g., /admin/collections/blog
label: "Blog" # Used in the UI
folder: "content/blog/posts" # The path to the folder where the documents are stored
create: true # Allow users to create new documents in this collection
slug: "{{year}}-{{month}}-{{day}}-{{slug}}" # Filename template, e.g., YYYY-MM-DD-title.md
format: 'json'
sort: "date:desc" # Default is title:asc
fields: # The fields for each document, usually in front matter
- {label: "Title", name: "title", widget: "string"}
- {label: "Publish Date", name: "date", widget: "datetime"}
- {label: "Featured Image", name: "thumbnail", widget: "image", required: false}
- {label: "Category", name: "category", widget: "relation", collection: "blogcategories", searchFields: "title", valueField: "title", displayFields: ["title", "description"], required: false}
- {label: "Body", name: "body", widget: "markdown"}
- name: "page" # Used in routes, e.g., /admin/collections/blog
label: "Pages" # Used in the UI
folder: "content/page/posts" # The path to the folder where the documents are stored
create: true # Allow users to create new documents in this collection
slug: "{{slug}}" # Filename template, e.g., YYYY-MM-DD-title.md
format: 'json'
fields: # The fields for each document, usually in front matter
- {label: "Title", name: "title", widget: "string"}
- {label: "Publish Date", name: "date", widget: "datetime"}
- {label: "Featured Image", name: "thumbnail", widget: "image", required: false}
- {label: "Body", name: "body", widget: "markdown"}
- label: "Setup"
name: "setup"
files:
- label: "Site Info"
name: "info"
format: 'json'
file: "content/setup/info.json"
fields:
- {label: Site Name, name: sitename, widget: string}
- {label: Site Description, name: sitedescription, widget: string}
- label: Menu
name: menu
widget: list
fields:
- {label: Name, name: name, widget: string}
- {label: Position, name: position, widget: string}
- {label: Link, name: link, widget: string}
- label: "Connect"
name: "connect"
format: 'json'
file: "content/setup/connect.json"
fields:
- label: 'Links'
name: 'connectlinks'
widget: 'list'
fields:
- {label: Link Name, name: name, widget: string}
- {label: URL, name: url, widget: string}
- label: 'Categories'
name: 'blogcategories'
folder: "content/categories/posts" # The path to the folder where the documents are stored
create: true # Allow users to create new documents in this collection
slug: "{{slug}}" # Filename template, e.g., YYYY-MM-DD-title.md
format: 'json'
fields:
- {label: Title, name: title, widget: string}
- {label: Description, name: description, widget: string, required: false}
- label: 'Tags'
name: 'blogtags'
folder: "content/tags/posts" # The path to the folder where the documents are stored
create: true # Allow users to create new documents in this collection
slug: "{{slug}}" # Filename template, e.g., YYYY-MM-DD-title.md
format: 'json'
fields:
- {label: Title, name: title, widget: string}
I also found the relation
widget quite brittle if you accidentally miss required options or pass a wrong type. I hope https://github.com/netlify/netlify-cms/pull/1363 will help with that.
@jake-101, I think the error in this case is that searchFields: "title"
should have been passed as an array, ie. searchFields: ["title"]
.
thanks so much, i thought it wouldn't need an array with only one value. i'll try it later and close this for now.
This worked and fixed my issue.
Most helpful comment
This worked and fixed my issue.