How do I display the Category Names in the dropdown, as opposed to their ID string? Currently they're labeled as Untitled, though they have label names.
import { CollectionConfig } from 'payload/types';
const Items: CollectionConfig = {
slug: 'items',
admin: {
useAsTitle: 'name',
},
access: {
read: () => true,
},
fields: [
{
name: 'name',
type: 'text',
},
{
name: 'description',
type: 'text',
},
{
name: 'category',
type: "relationship",
relationTo: "portfolioCategories",
},
],
timestamps: false,
}
export default Items;
import { CollectionConfig } from 'payload/types';
const PortfolioCategories: CollectionConfig = {
slug: 'portfolioCategories',
admin: {
useAsTitle: 'title',
},
access: {
read: () => true,
},
fields: [
{
name: 'name',
label: 'Portfolio Categories',
type: 'text',
},
],
timestamps: false,
}
export default PortfolioCategories;
useAsTitle needs to be a field on the collection - use "name" instead of "title" 🙂
That worked, thanks.
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.