Skip to content

1954 array item fix #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions frontend/.changeset/early-foxes-stick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'pydantic-forms': patch
---

Fixes title and description on array items
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,24 @@ const getPydanticFormField = (
requiredFields: string[],
formLabels?: Record<string, string>,
fieldDetailProvider?: PydanticFormsContextConfig['fieldDetailProvider'],
isArrayItem: boolean = false, // Arrayitems should not have titles or descriptions. Their properties will have them instead
) => {
const options = getFieldOptions(propertySchema);
const fieldOptionsEntry = getFieldAllOfAnyOfEntry(propertySchema);

const pydanticFormField: PydanticFormField = {
id,
title:
translateLabel(propertyId, propertySchema.title, formLabels) ||
propertyId,
description: translateLabel(
`${propertyId}_info`,
propertySchema.description,
formLabels,
),
title: !isArrayItem
? translateLabel(propertyId, propertySchema.title, formLabels) ||
propertyId
: '',
description: !isArrayItem
? translateLabel(
`${propertyId}_info`,
propertySchema.description,
formLabels,
)
: '',
arrayItem: propertySchema.items
? getPydanticFormField(
propertySchema.items,
Expand Down Expand Up @@ -121,6 +125,7 @@ const parseProperties = (
formLabels,
fieldDetailProvider,
);

if (propertySchema.type === PydanticFormFieldType.ARRAY) {
// When the property is an array, we need to parse the item that is an array element
// Currently we only support arrays of single field types so items can never be multiple items
Expand All @@ -135,6 +140,7 @@ const parseProperties = (
requiredFields,
formLabels,
fieldDetailProvider,
true,
);
}

Expand Down