Skip to content

Commit dbeb293

Browse files
author
Ruben van Leeuwen
committed
2076: Adds const attribute to PydanticFormField definition
1 parent 1b079a0 commit dbeb293

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ const getPydanticFormField = (
7676
formLabels,
7777
)
7878
: '';
79+
80+
const constValue = flatSchema.const || undefined;
81+
7982
const arrayItem = flatSchema.items
8083
? getPydanticFormField(
8184
flatSchema.items,
@@ -107,6 +110,7 @@ const getPydanticFormField = (
107110
required,
108111
validations,
109112
columns: 6, // TODO: Is this still relevant? https://github.com/workfloworchestrator/orchestrator-ui-library/issues/1891
113+
...(constValue && { const: constValue }),
110114
properties,
111115
...fieldDetailProvider?.[propertyId],
112116
};

frontend/packages/pydantic-forms/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export interface PydanticFormField {
9696
default?: PydanticFormFieldValue;
9797
columns: number;
9898
required: boolean;
99+
const?: PydanticFormFieldValue | null;
99100
schema: PydanticFormPropertySchemaParsed;
100101
validations: PydanticFormFieldValidations;
101102
attributes: PydanticFormFieldAttributes;

0 commit comments

Comments
 (0)