Merge pull request #15 from payloadcms/fix/14/localized-groups
fix: localized groups
This commit is contained in:
@@ -81,7 +81,7 @@ const traverseFields = (args: Arguments): void => {
|
||||
dataCopy[field.name] = JSON.parse(data[field.name] as string);
|
||||
}
|
||||
|
||||
const hasLocalizedValue = (typeof data[field.name] === 'object' && data[field.name] !== null)
|
||||
const hasLocalizedValue = (typeof data?.[field.name] === 'object' && data?.[field.name] !== null)
|
||||
&& field.name
|
||||
&& field.localized
|
||||
&& locale !== 'all'
|
||||
|
||||
@@ -73,18 +73,6 @@ export default function localizationPlugin(schema: any, options): void {
|
||||
return value;
|
||||
})
|
||||
.set(function (value) {
|
||||
// multiple locales are set as an object
|
||||
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
||||
const { locales } = options;
|
||||
locales.forEach((locale) => {
|
||||
if (!value[locale]) {
|
||||
return;
|
||||
}
|
||||
this.set(`${path}.${locale}`, value[locale]);
|
||||
}, this);
|
||||
return;
|
||||
}
|
||||
|
||||
// embedded and sub-documents will use locale methods from the top level document
|
||||
const owner = this.ownerDocument ? this.ownerDocument() : this;
|
||||
const locale = owner.getLocale();
|
||||
|
||||
Reference in New Issue
Block a user