keystonejs / keystone

The superpowered headless CMS for Node.js — built with GraphQL and React
https://keystonejs.com
MIT License
9.18k stars 1.15k forks source link

when I use Relationship ,the Admin only show "ID",not the title #2609

Closed ghost closed 4 years ago

ghost commented 4 years ago

Question about Keystone

GitHub Issues are reserved for Bug reports and Feature requests.

The best place to get a question answered is sign-up to our Slack: http://community.keystonejs.com/ image image as is show above,I init when the project start,but I use the RelationShip,in the adminUI,Only show id like 1,2,3

timleslie commented 4 years ago

The contents of the select component for a relationship use the labelField of the related list. By default it will look for a field called name. If this doesn't exist it will use the id field, which is what you are seeing. You can configure the field used with the labelField config option. If you would like it to use the postition field you can do:

module.exports = {
  fields: { position: { type: Text, ... } },
  labelField: "position",
};