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.

How to customize options text in relationship field?

default discord avatar
.pixelpoint4 months ago
3

I'm trying to use PayloadCMS with Postgres and stuck on relationship type of field. When I use it, it uses a primary key "id" as a text for options inside the dropdown, when I want title to be used instead. It feels like a bug specifically with Postgres, since based on all examples availalbe there should not be any extra code, however anyway I can't find a way to customizing these texts since it also feels like quite an obvious feature.



Perfect, thank you very much for very quick response. It helped. I think it would be great mentioning it inside Relationship documentation page.

  • default discord avatar
    paulpopuslast year

    In your referenced collection are you setting up your

    admin.useAsTitle

    configuration?

    https://payloadcms.com/docs/configuration/collections#admin-options

    this is what tells the cms what field it can use as a preview/title



    For sure!

  • default discord avatar
    deankemball11 months ago

    i get this error:


    'useAsTitle' does not exist in type 'Admin'



    how did you implement it

    @1060516554271379469

    ?


    this is my config:


     {
          name: 'artist',
          label: 'Artist',
          type: 'relationship',
          relationTo: 'artists',
          admin: {
            sortOptions: 'name',
            useAsTitle: 'name',
          },
        },
  • default discord avatar
    haidong34065 months ago

    May I ask about custom relationship field. I have a relationship field code in Product collection which list out lis of codes. Each code belong to one category. The proplem is when i create new product. It's very hard to know the category of code since i have thoundsans of them

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.