mirror of
https://github.com/strapi/strapi.git
synced 2025-09-22 23:09:47 +00:00
don't clean creator fields because they are not sended to backend
This commit is contained in:
parent
41844c2867
commit
3ec34be1ab
@ -236,17 +236,14 @@ const reducer = (state, action) =>
|
||||
|
||||
const findAllRelationsAndReplaceWithEmptyArray = findAllAndReplace(
|
||||
components,
|
||||
(value) => {
|
||||
return value.type === 'relation';
|
||||
},
|
||||
(value, { path }) => {
|
||||
const relationFieldName = path[path.length - 1];
|
||||
|
||||
// When editing, we don't want to fetch the relations with creator fields because we already have it
|
||||
if (value && (relationFieldName === 'createdBy' || relationFieldName === 'updatedBy')) {
|
||||
return value;
|
||||
}
|
||||
// We don't replace creator fields because we already return them without need to populate them separately
|
||||
const isCreatorField =
|
||||
path[path.length - 1] === 'createdBy' || path[path.length - 1] === 'updatedBy';
|
||||
|
||||
return value.type === 'relation' && !isCreatorField;
|
||||
},
|
||||
(_, { path }) => {
|
||||
if (state.modifiedData?.id === data.id && get(state.modifiedData, path)) {
|
||||
return get(state.modifiedData, path);
|
||||
}
|
||||
|
@ -29,6 +29,11 @@ const cleanData = ({ browserState, serverState }, currentSchema, componentsSchem
|
||||
*/
|
||||
const recursiveCleanData = (browserState, serverState, schema, pathToParent) => {
|
||||
return Object.keys(browserState).reduce((acc, current) => {
|
||||
// Creator attributes can be safely ignored because they are handle on the backend
|
||||
if (current === 'createdBy' || current === 'updatedBy') {
|
||||
return acc;
|
||||
}
|
||||
|
||||
const path = pathToParent ? `${pathToParent}.${current}` : current;
|
||||
const attrType = getType(schema, current);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user