Hi. When I create Categories, the display name is the ID string, I'd like it to be the same as it's title. How do I go about this?
Repo:
https://github.com/taunhealy/Melex_CMSCategories.ts
import { CollectionConfig } from 'payload/types';
const Categories: CollectionConfig = {
slug: 'categories',
admin: {
useAsTitle: 'name',
},
access: {
read: () => true,
},
fields: [
{
name: 'name',
type: 'text',
},
],
timestamps: false,
}
export default Categories;
I've inputted 'Road-Legal'. I'd like that to display as the ID name when I view the differing categories.
I'm using the PayloadCMS E-commerce template
Hi
@479030528084017165, you can change the columns that appear in the List view by adding an array of field names to your collection config.
admin: {
useAsTitle: 'name',
defaultColumns: [
'name',
// any other columns you want to show
],
},
Will it be considered good practice to have a unique string rather than the name of the category? Or for simplicity sake can I auto-name the ID?
Personally, I would always leave a ID, just in case I want to query by that specific document, and there is less of a chance of accidentally duplicating a custom-set ID.
But, if you really wanted to, you can easily set a custom ID in Payload by passing in an ID field:
{
fields: [
{
name: 'id',
type: 'number',
// can also be of type: 'text'
},
],
}
Thanks
@783701636165402624. Do you know how I can move the 'name' column to appear as the first column? How do I re-order these in general?
Star
Discord
online
Get dedicated engineering support directly from the Payload team.