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

Remove requirement for 'title' field in folder collections #1802

Closed
honeyspoon opened this issue Oct 9, 2018 · 2 comments · Fixed by #1543
Closed

Remove requirement for 'title' field in folder collections #1802

honeyspoon opened this issue Oct 9, 2018 · 2 comments · Fixed by #1543

Comments

@honeyspoon
Copy link

I'm not sure if this should be considered as a feature request or as a bug.

General

The 'title' field seems to be required in folder collections according to the documentation

The config file checks that requirement at initialization ever since release 2.0.

This requirement was put in place because the generated slug uses the 'title' field.

My problem

My particular use case of the cms would require me having a folder collection that references JSON files. I don't want to add a title property for in my files.
I already have a field that could be used as an identifier 'uid'

config.yml

here is my configuration for the affected folder collection

  - name: "author"
    label: "Authors"
    folder: "content/authors"
    create: true
    slug: "{{uid}}.json"
    fields:      
      - {label: "UID", name: "uid", widget: "string"}
      - {label: "Name", name: "name", widget: "string"}
      - {label: "Profile picture", name: "image", widget: "image"}
      - {label: "Website", name: "url", widget: "string"}
      - {label: "Bio", name: "bio", widget: "string"}
      - {label: "Social Urls", name: "social", widget: "list"}

As you can see, I don't have a title field.
I also have defined a custom slug that uses my own identifier.

This current configuration gives me an error message:
Error loading the CMS configuration Config Errors: 'collections[1]' must have a field that is a valid entry identifier Check your config.yml file.

Possible solutions

Adding a title field to my collection

I can add a title field to my collection and that would fix the error message, but it would add a field that I have no need for and that I cannot leave blank for items in my collection.
Seems like a bad practice.

Removing the requirement for 'title' field when using cutom slug

Since this requirement is only here to ensure the slug will work (not sure if its the only reason), we could simply not check it when a custom slug is defined.

Changing requirement for a custom identifier

The current code checks if the collection has identifier fields.
The only two identifier fields are currently 'title' and 'path' source
I could specify my own identifier field like this feature request suggests and it would add my field to 'title' and 'path' as an indentifier.
This would fix the error.

Change perspective

Maybe I'm using the cms for something it was not indented to do and I should not be able to edit these kind of files.

Contex

netlify-cms v 2.1.2

@kennedyrose
Copy link

We've run into the same problem. We usually just change the ID field to "title" but it feels a little hacky and could lead to some confusion during development.

@ascorbic
Copy link
Contributor

To be clear, #1543 isn't a feature request: it's a working PR that adds support for this (or at least it was when I opened it, it probably needs updating now)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants