Skip to content

Commit 82035b5

Browse files
author
Ruben van Leeuwen
committed
1954: Fix arrayItems copying title and description from array field
1 parent 9029768 commit 82035b5

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

frontend/packages/pydantic-forms/src/core/hooks/usePydanticFormParser.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,24 @@ const getPydanticFormField = (
4545
requiredFields: string[],
4646
formLabels?: Record<string, string>,
4747
fieldDetailProvider?: PydanticFormsContextConfig['fieldDetailProvider'],
48+
isArrayItem: boolean = false,
4849
) => {
4950
const options = getFieldOptions(propertySchema);
5051
const fieldOptionsEntry = getFieldAllOfAnyOfEntry(propertySchema);
5152

5253
const pydanticFormField: PydanticFormField = {
5354
id,
54-
title:
55-
translateLabel(propertyId, propertySchema.title, formLabels) ||
56-
propertyId,
57-
description: translateLabel(
58-
`${propertyId}_info`,
59-
propertySchema.description,
60-
formLabels,
61-
),
55+
title: !isArrayItem
56+
? translateLabel(propertyId, propertySchema.title, formLabels) ||
57+
propertyId
58+
: '',
59+
description: !isArrayItem
60+
? translateLabel(
61+
`${propertyId}_info`,
62+
propertySchema.description,
63+
formLabels,
64+
)
65+
: '',
6266
arrayItem: propertySchema.items
6367
? getPydanticFormField(
6468
propertySchema.items,
@@ -121,6 +125,7 @@ const parseProperties = (
121125
formLabels,
122126
fieldDetailProvider,
123127
);
128+
124129
if (propertySchema.type === PydanticFormFieldType.ARRAY) {
125130
// When the property is an array, we need to parse the item that is an array element
126131
// Currently we only support arrays of single field types so items can never be multiple items
@@ -135,6 +140,7 @@ const parseProperties = (
135140
requiredFields,
136141
formLabels,
137142
fieldDetailProvider,
143+
true,
138144
);
139145
}
140146

0 commit comments

Comments
 (0)