When adding a relationship I would like to show the title in the item selector instead of the id, how can I achieve this.
Collection field looks like this:
{
name: 'participated',
label: 'Participated',
type: 'relationship',
hasMany: true,
relationTo: [
'camps', 'labs', 'sessions'
],
admin: {
allowCreate: false,
}
}
You can make this change on the relevant collection. Use
useAsTitle
Quoting the doc
Specify a top-level field to use for a document title throughout the Admin panel. If no field is defined, the ID of the document is used as the title.
saved the day, been banging my head for weeks. Assumed it was on the relationship type itself. THANK YOU!!!!
do u know if there is the possibilty to join values for 'useAsTitle'? For example displaying a relationship as part of the title. [Manufacturer.name] + [name]
I was looking for this today as well. Still haven't found an answer yet.
@1005175744474927194
Have you tried virtual fields?
https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challengesah this helps, thanks!
when you were digging in to this, did you find any way to render something other than text in the relationship dropdown? I'm trying to show an image thumbnail but haven't found a way to customize the dropdown item components
Not yet. I only needed to display other text
This helped me a lot! It would be great if we could add something to the docs for Relationships, since the default of showing an ID is an unpleasant look, and I had to look in Discord to find this
Star
Discord
online
Get dedicated engineering support directly from the Payload team.