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

Allow displaying a different field that the linked valueField in Relation widget #591

Closed
medfreeman opened this issue Sep 11, 2017 · 6 comments

Comments

@medfreeman
Copy link

medfreeman commented Sep 11, 2017

- Do you want to request a feature or report a bug?

Feature
Needs #597 first.

- What is the current behavior?

The Relation widget allows linking to another collection item.
The searchFields property defines in what item fields netlify will look for the user provided string.
The valueField property defines what value will be stored in the relation field, thus creating a link between the current item and searched item.

- Context

I created a menus collection that can link to pages collection items on two levels:

  - name: "menus"
    label: "Menu"
    editor:
      preview: false
    folder: "content/menus"
    create: true
    widget: "object"
    fields:
      - { label: "Title", name: "title", widget: "string" }
      - label: "Items"
        name: "items"
        widget: "list"
        fields:
          - { label: "Page", name: "page", widget: "relation", collection: "pages", searchFields: ["title", "body"], valueField: "uuid" }
          - label: "Items"
            name: "items"
            widget: "list"
            fields:
              - { label: "Page", name: "page", widget: "relation", collection: "pages", searchFields: ["title", "body"], valueField: "uuid" }

I also created an uuid read-only widget that allows linking to a page by a constant unique per-item field, thus preventing the menu links to break in the case the valueField is set to title and the user changes the page title for example.

- What is the expected behavior?

Add a displayField property that would allow displaying a different field that the linked valueField.

In my above example i would have uuid as valueField and title as displayField.
The user would see the page title as menu entry, but the stored value would be the uuid.

medfreeman added a commit to medfreeman/netlify-cms that referenced this issue Sep 12, 2017
medfreeman added a commit to medfreeman/netlify-cms that referenced this issue Sep 14, 2017
medfreeman added a commit to medfreeman/netlify-cms that referenced this issue Sep 16, 2017
@barthc
Copy link
Contributor

barthc commented Jan 9, 2019

@tomrutgers please confirm this issue is already fixed in #1303 before closing.

@tomrutgers
Copy link
Contributor

Correct. You can now use displayFields: []. It defaults to valueField

@papandreou
Copy link
Contributor

@tomrutgers, displayFields only has an effect on the autocompleter, though, not when a related entry has been selected. This means that a relation to a "id" like field will look user unfriendly most of the time:

screen shot 2019-01-09 at 13 40 22

... I think this is what the OP means.

Also discussed here: #1982 (comment)

@tomrutgers
Copy link
Contributor

This issue was opened when there wasn't a displayFields property available, so it is a bit different from #1982 I suppose. Since then a displayFields has been added but it has it issues for selection. Would you like to keep both issues open @papandreou?

@papandreou
Copy link
Contributor

@tomrutgers, hmm, I think #1982 covers the remaining bits pretty well, so it's fine that this one is closed. Just wanted to clarify 👍

@tomrutgers
Copy link
Contributor

Agreed 👍
Thanks for your input!

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

Successfully merging a pull request may close this issue.

6 participants