payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
23.57k stars 1.5k forks source link

Array field inside localized group field is not saved #8322

Closed ivankyrpa closed 1 week ago

ivankyrpa commented 1 week ago

Link to reproduction

https://github.com/ivankyrpa/payload-cms-beta-107

Environment Info

Binaries:
  Node: 20.12.2
  pnpm: 9.10.0
Relevant Packages:
  payload: 3.0.0-beta.107
  next: 15.0.0-canary.104
  @payloadcms/db-postgres: 3.0.0-beta.107
  @payloadcms/email-nodemailer: 3.0.0-beta.107
  @payloadcms/graphql: 3.0.0-beta.107
  @payloadcms/next/utilities: 3.0.0-beta.107
  @payloadcms/plugin-cloud: 3.0.0-beta.107
  @payloadcms/richtext-lexical: 3.0.0-beta.107
  @payloadcms/translations: 3.0.0-beta.107
  @payloadcms/ui/shared: 3.0.0-beta.107
  react: 19.0.0-rc-06d0b89e-20240801
  react-dom: 19.0.0-rc-06d0b89e-20240801

Describe the Bug

Since the original issue was not resolved I open another one.

Reproduction Steps

Please see the repo to re-product the issue. I utilized npx create-payload-app@beta command to create the project.

Test global looks like that:

 export const TestGlobal: GlobalConfig = {
  slug: 'testGlobal',
  fields: [
    {
      name: 'group',
      localized: true,
      type: 'group',
      fields: [
        {
          name: 'innerArray',
          type: 'array',
          maxRows: 1,
          fields: [
            {
              type: 'row',
              fields: [
                {
                  name: 'field1',
                  type: 'text',
                },
                {
                  name: 'field2',
                  type: 'text',
                },
              ],
            },
            ...
          ],
        }
      ]
    }
  ],
}

Payload config:


...
import { TestGlobal } from './globals/TestGlobal'

export default buildConfig({
  ...
  globals: [TestGlobal],
  ...
  }),
  localization: {
    defaultLocale: 'en',
    locales: ['en', 'de'],
    fallback: true,
  },
  ...
})

### Adapters and Plugins

db-postgres
Because789 commented 1 week ago

Just a shot in the dark, do you have the same issue, when starting the project with npx create-payload-app@beta --use-pnpm? I had some issues when I didn't use the --use-pnpm flag, but don't remember what they were exactly...

danielkoller commented 1 week ago

I also have a weird bug with a global. When using an umlaut ("Länder") it throws this error ->

ERROR: error: invalid byte sequence for encoding "UTF8": 0xe4 0x6e 0x64

import { GlobalConfig } from 'payload'

export const StatsBanner: GlobalConfig = {
  slug: 'statsBanner',
  label: {
    en: 'Stats Banner',
    de: 'Statistik-Banner',
  },
  fields: [
    {
      name: 'stats',
      type: 'array',
      required: true,
      maxRows: 4,
      fields: [
        {
          name: 'label',
          type: 'text',
          required: true,
          label: {
            en: 'Label',
            de: 'Bezeichnung',
          },
          localized: true,
        },
        {
          name: 'number',
          type: 'text',
          required: true,
          label: {
            en: 'Number',
            de: 'Zahl',
          },
          localized: true,
        },
        {
          name: 'subLabel',
          type: 'text',
          required: true,
          label: {
            en: 'Sub Label',
            de: 'Unterbezeichnung',
          },
          localized: true,
        },
      ],
    },
  ],
}

This is how my Global looks like. Maybe the bug is somehow related to your issue.

r1tsuu commented 1 week ago

Hey @ivankyrpa, thanks for the report! Fixed in this PR: https://github.com/payloadcms/payload/pull/8355

github-actions[bot] commented 1 week ago

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.

github-actions[bot] commented 4 days ago

🚀 This is included in version v3.0.0-beta.109