Add custom component for relationship select item #2934
Replies: 5 comments
-
Great suggestion, I think this would be a very useful option to have! My gut tells me that this should be at the collection level to avoid having to define that custom component in every relationship field (as I would imagine that the component is gonna be dependent on the collection's data more often than it will on the context of the relationship field), but maybe the solution is actually both? 🤔 Define the "default" at the collection level: {
slug: 'collection',
admin: {
components: {
relationship: MyCustomRelationshipItem,
}
}
} then optionally in another collection, at the field level, have the ability to override the component: {
slug: 'otherCollection',
fields: [
{
type: 'relationship',
name: 'collection',
relationTo: [
{
collection: 'collection',
component: AnotherCustomRelationshipItem,
}
]
}
]
} |
Beta Was this translation helpful? Give feedback.
-
I have been looking for something like this as well, would love to see this implemented! |
Beta Was this translation helpful? Give feedback.
-
Yes, that would help a lot! Great idea |
Beta Was this translation helpful? Give feedback.
-
Not sure if this is in the works but this would be a godsend for my projects! |
Beta Was this translation helpful? Give feedback.
-
Bump this idea |
Beta Was this translation helpful? Give feedback.
-
Per this discussion: https://discord.com/channels/967097582721572934/1123646638544662600/1123646638544662600
TLDR it would be really helpful to allow us to customize the DropdownItem used in
relationship
fields. Right now it defaults to the ID (or title, if set) which is generally helpful but doesn't allow you to add thumbnails. For a media or video collection sometimes the thumbnail itself is the only way to uniquely identify each item, so you need to click into the item itself to see what it's referencing.I'm not sure whether this better belongs:
admin.components
, so whenever that collection is used in a relationship field, it uses that component to render the items in the select.admin.components
for the relationship itself, so that each relationship can uniquely define the component that's rendered. This is probably the better option since it's more flexible.Here's a rough mock of what this would allow, making relationship selects much easier:
Beta Was this translation helpful? Give feedback.
All reactions