From b4c2061ba9d5f203b22bdb78fac7ab5023e152cc Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 7 Nov 2024 16:29:19 +0000 Subject: [PATCH] Make the field setting on fields optional, and use the component name as a fallback --- packages/builder/src/dataBinding.js | 7 ++++--- packages/client/manifest.json | 6 ++---- packages/client/src/components/app/forms/Field.svelte | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/builder/src/dataBinding.js b/packages/builder/src/dataBinding.js index 8adc27ee59..c89221f163 100644 --- a/packages/builder/src/dataBinding.js +++ b/packages/builder/src/dataBinding.js @@ -1141,10 +1141,11 @@ export const buildFormSchema = (component, asset) => { const fieldSetting = settings.find( setting => setting.key === "field" && setting.type.startsWith("field/") ) - if (fieldSetting && component.field) { + if (fieldSetting) { const type = fieldSetting.type.split("field/")[1] - if (type) { - schema[component.field] = { type } + const key = component.field || component._instanceName + if (type && key) { + schema[key] = { type } } } component._children?.forEach(child => { diff --git a/packages/client/manifest.json b/packages/client/manifest.json index 0feac0ee80..bf7cd78ad9 100644 --- a/packages/client/manifest.json +++ b/packages/client/manifest.json @@ -3105,8 +3105,7 @@ { "type": "field/string", "label": "Field", - "key": "field", - "required": true + "key": "field" }, { "type": "text", @@ -3524,8 +3523,7 @@ { "type": "field/options", "label": "Field", - "key": "field", - "required": true + "key": "field" }, { "type": "text", diff --git a/packages/client/src/components/app/forms/Field.svelte b/packages/client/src/components/app/forms/Field.svelte index 846bfa6eef..b2be00ca47 100644 --- a/packages/client/src/components/app/forms/Field.svelte +++ b/packages/client/src/components/app/forms/Field.svelte @@ -35,7 +35,7 @@ $: formStep = formStepContext ? $formStepContext || 1 : 1 $: formField = formApi?.registerField( - field, + field || $component.name, type, defaultValue, disabled,