Skip to content

Commit baf52f5

Browse files
authored
Merge pull request #126 from workfloworchestrator/1954-array-item-fix
1954 array item fix
2 parents a4adde4 + dad865d commit baf52f5

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'pydantic-forms': patch
3+
---
4+
5+
Fixes title and description on array items

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, // Arrayitems should not have titles or descriptions. Their properties will have them instead
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)