Skip to content

Custom IDs with type text doesn't work properly #12381

@ondrejkouba

Description

@ondrejkouba

Describe the Bug

I want to use ID as a text -> reason for this is that I have to (because of client) to use Nuxt as frontend and I wan to use Payload as the CMS. I thought that elegant solution would be to have collection Pages which has a ID of type text so I can just get the slug from Nuxt and query payload collection pages by this slug.

This is my collection config:
`import { CollectionConfig } from 'payload';

export const Pages: CollectionConfig = {
slug: 'pages',
admin: {
group: 'Content',
},
fields: [
{
type: 'text',
name: 'id',
required: true,
unique: true,
index: true,
},
],
};
`

Postgres I run fresh from docker.

Observed behavior is that I am in fact able to create the element and it is displayed in the list view with a correct ID. However after creation of an element in collection it shows NaN with a new form and when I click on the element in the ListView and edit it, it doesn't show anything and shows again NaN.

I am using latest payload (as of now v 3.37). It was recommended to me to change the idtype to UUID however this doesn't work either...

I checked with pgAdmin the table Pages and it contains entries with correct type.

Link to the code that reproduces this issue

Not really needed as creating env should be matter of a minute - one collection and in description

Reproduction Steps

Use Payload CMS with Posgress adapter and docker postgres latest.
Create new collection with field ID of type text.
Create a new element with id: test
Witness described behavior.

Which area(s) are affected? (Select all that apply)

area: ui

Environment Info

payload: 3.37.0
next: 15.3.0
node: 22.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions