payload
payload copied to clipboard
ID field's defaultValue does not work inside Array
Link to reproduction
No response
Environment Info
Node.js v18.20.4
Binaries:
Node: 18.20.4
npm: 10.7.0
Yarn: N/A
pnpm: 9.8.0
Relevant Packages:
payload: 3.0.0-beta.100
next: 15.0.0-canary.143
@payloadcms/db-postgres: 3.0.0-beta.100
@payloadcms/email-nodemailer: 3.0.0-beta.100
@payloadcms/graphql: 3.0.0-beta.100
@payloadcms/next/utilities: 3.0.0-beta.100
@payloadcms/plugin-cloud: 3.0.0-beta.100
@payloadcms/plugin-cloud-storage: 3.0.0-beta.100
@payloadcms/richtext-lexical: 3.0.0-beta.100
@payloadcms/richtext-slate: 3.0.0-beta.100
@payloadcms/storage-s3: 3.0.0-beta.100
@payloadcms/translations: 3.0.0-beta.100
@payloadcms/ui/shared: 3.0.0-beta.100
react: 19.0.0-rc-4f604941-20240830
react-dom: 19.0.0-rc-4f604941-20240830
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:21 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T8103
Available memory (MB): 16384
Available CPU cores: 8
Describe the Bug
The default value works for custom ID fields inside the collection itself. But it fails for ID fields inside an array field. Please see the following image:
Below is the collection definition:
export const Test: CollectionConfig = {
slug: 'test',
fields: [
{
name: 'id',
type: 'number',
defaultValue: 1111,
},
{
name: 'children',
type: 'array',
fields: [
{
name: 'id',
type: 'number',
defaultValue: 1111,
},
{
name: 'swatch',
type: 'relationship',
relationTo: 'swatch' as CollectionSlug,
},
{
name: 'gallery',
type: 'upload',
relationTo: 'media',
hasMany: true,
},
],
},
],
}
Reproduction Steps
As Above
Adapters and Plugins
No response
This issue has been marked as stale due to lack of activity.
To keep this issue open, please indicate that it is still relevant in a comment below.