Skip to content

Commit f3ee3c1

Browse files
committed
fix(app-headless-cms): use defaultValue from field settings
1 parent ff2524a commit f3ee3c1

File tree

1 file changed

+10
-2
lines changed
  • packages/app-headless-cms/src/admin/components/ContentEntryForm

1 file changed

+10
-2
lines changed

packages/app-headless-cms/src/admin/components/ContentEntryForm/useBind.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,27 @@ export function useBind({ Bind, field }: UseBindProps) {
5757
const isMultipleValues = index === -1 && field.multipleValues;
5858
const inputValidators = isMultipleValues ? listValidators : validators;
5959

60+
const defaultValueFromSettings = field.settings
61+
? (field.settings.defaultValue as any)
62+
: null;
63+
64+
const indexDefaultValue = field.multipleValues
65+
? (defaultValueFromSettings ?? [])[index]
66+
: null;
67+
6068
memoizedBindComponents.current[componentId] = function UseBind(params: UseBindParams) {
6169
const {
6270
name: childName,
6371
validators: childValidators,
6472
children,
65-
defaultValue
73+
defaultValue = index === -1 ? defaultValueFromSettings : indexDefaultValue
6674
} = params;
6775

6876
return (
6977
<Bind
7078
name={childName || name}
7179
validators={childValidators || inputValidators}
72-
defaultValue={!isMultipleValues ? defaultValue : null}
80+
defaultValue={defaultValue ?? undefined}
7381
>
7482
{bind => {
7583
// Multiple-values functions below.

0 commit comments

Comments
 (0)