decaporg / decaporg/decap-cms

Setting folder collections path overrides slug value

Open
#4,092 8 comments 6 reactions 0 assignees View on GitHub
area: slugs status: unconfirmed type: bug
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

**Describe the bug**
When using the [folder collections path](https://www.netlifycms.org/docs/beta-features/#folder-collections-path) option, the value of `slug` becomes that of `path` rather than just the slugified version of `title` or `identifier_field`.

**To Reproduce**
1. Create a collection and set `path` to `path: "{{slug}}/_index"`
2. Define a field for `title`
3. Create a new record
4. In a new collection create a relation widget and reference the original collection and set `valueField: {{slug}}`
5. Save a record in the new collection

**Expected behavior**
The value of of the relation widget to be just the slugified version of `title`, instead it's the entire path as defined in `path` (`my-title-slug/_index`).

**Screenshots**

**Applicable Versions:**

- Netlify CMS version: 2.10.55

**CMS configuration**
```
collections:
- name: "topics"
label: "Topics"
folder: "content/topics"
path: "{{slug}}/_index"
create: true
fields:
- label: "Topic Title"
name: "title"
widget: "string"
hint: "Short, topical, no acronyms."

- name: "events"
label: "Events"
label_singular: "Event"
folder: "content/events"
fields:
- label: "Topics"
name: "topics"
widget: "relation"
collection: "topics"
searchFields: ["title"]
valueField: "{{slug}}"
displayFields: ["title"]
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.