Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

change field that is displayed in relationship field dropdown

default discord avatar
opie64467 months ago
5

From what I understand, in the collection’s CollectionConfig that you want the specific field to be displayed instead of the

id

, try adding the following:



admin: {
    useAsTitle: 'title',
  },
  • default discord avatar
    bilashism8 months ago

    How you've solved it? I'm facing the same issue.

  • default discord avatar
    christianjmaylast year

    you're very welcome!

  • default discord avatar
    br0ncelast year

    Thanks!

  • default discord avatar
    christianjmaylast year
    @273116181777481739

    if you want the name to be used across payload to identify documents in that collection, you can set

    admin.useAsTitle

    in its collection config:

    https://payloadcms.com/docs/configuration/collections#admin-options
  • default discord avatar
    br0ncelast year
    const Tag: CollectionConfig = {
      slug: 'tags',
      fields: [
        {
          name: 'product',
          type: 'relationship',
          relationTo: 'products',
          required: true,
        },
        {
          name: 'date_given_out',
          type: 'date',
          required: true,
        },
      ],
    };
    export default Tag


    With this code, the dropdown will display the Id of my products. I want

    product.name

    to be displayed instead. I couldn't find in the documentation where to set this.

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.