### What? Allows document to successfully be saved when `fallback to default locale` checked without throwing an error. ### Why? The `fallback to default locale` checkbox allows users to successfully save a document in the admin panel while using fallback data for required fields, this has been broken since the release of `v3`. Without the checkbox override, the user would be prevented from saving the document in the UI because the field is required and will throw an error. The logic of using fallback data is not affected by this checkbox - it is purely to allow saving the document in the UI. ### How? The `fallback` checkbox used to have an `onChange` function that replaces the field value with null, allowing it to get processed through the standard localization logic and get replaced by fallback data. However, this `onChange` was removed at some point and the field was passing the actual checkbox value `true`/`false` which then breaks the form and prevent it from saving. This fallback checkbox is only displayed when `fallback: true` is set in the localization config. This PR also updated the checkbox to only be displayed when `required: true` - when it's the field is not `required` this checkbox serves no purpose. Also adds tests to `localization/e2e`. Fixes #11245 --------- Co-authored-by: Jarrod Flesch <jarrodmflesch@gmail.com>
21 lines
371 B
TypeScript
21 lines
371 B
TypeScript
import type { CollectionConfig } from 'payload'
|
|
|
|
export const arrayCollectionSlug = 'array-fields'
|
|
|
|
export const ArrayCollection: CollectionConfig = {
|
|
slug: arrayCollectionSlug,
|
|
fields: [
|
|
{
|
|
name: 'items',
|
|
type: 'array',
|
|
localized: true,
|
|
fields: [
|
|
{
|
|
name: 'text',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
}
|