payload icon indicating copy to clipboard operation
payload copied to clipboard

ID field's defaultValue does not work inside Array

Open bmamouri opened this issue 1 year ago • 1 comments

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:

Screenshot 2024-09-09 at 5 45 56 AM

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

bmamouri avatar Sep 08 '24 19:09 bmamouri

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.

github-actions[bot] avatar Dec 13 '24 05:12 github-actions[bot]