Localized Block with localized fields unable to save values across multiple locales
Link to reproduction
No response
Payload Version
beta.87
Node Version
20 LTS
Next.js Version
15.0.0-canary.104
Describe the Bug
It's not possible to autosave/publish content across multiple locales if we are using a localized field within an array field.
For example, I'm currently using the beta demo project (with multiple locales) and I have created a localized Block with one array field that also contains one localized text field (field1).
The first time I configure this content for any locale, I have no issues. If I then try to configure the same Block in another locale, I keep having this error:
ERROR: There was an error while saving a version for the Page with ID 1.
ERROR: Cannot read properties of undefined (reading '_pages_v_blocks_array_block_list_locales_locale_parent_id_uniqu')
This causes the autosave and publishing actions to no work and the value in the localized field is not stored in the database.
I have only encountered this issue for localized fields inside the array field.
This is the field I added to the Pages collection fields
{
name: 'content',
label: 'Content',
type: 'blocks',
localized: true,
blocks: [ArrayBlock],
}
And this is the ArrayBlock that I'm using for testing
export const ArrayBlock: Block = {
slug: 'arrayBlock',
interfaceName: 'ArrayBlock',
fields: [
{
type: 'array',
name: 'List',
label: 'List',
fields: [
{
type: 'group',
name: 'Element',
fields: [
{
name: 'field1',
type: 'text',
label: 'Field1',
localized: true,
required: true,
},
],
},
],
},
],
}
This is the behaviour I'm experiencing
https://github.com/user-attachments/assets/2c346475-ef30-445d-aef3-4ac4c8df68d0
Reproduction Steps
- Use the beta demo project
- Update to version 87
- Create the ArrayBlock Block and add this to the
Pagescollection (as described above) - Run the necessary migrations
- Follow the same steps as the ones in the video
- Any autosave/publishing action triggers the
_pages_v_blocks_array_block_list_locales_locale_parent_id_uniquconstraint
Adapters and Plugins
db-postgres