Make the field setting on fields optional, and use the component name as a fallback

This commit is contained in:
Andrew Kingston 2024-11-07 16:29:19 +00:00
parent 26956f4f2e
commit b4c2061ba9
No known key found for this signature in database
3 changed files with 7 additions and 8 deletions

View File

@ -1141,10 +1141,11 @@ export const buildFormSchema = (component, asset) => {
const fieldSetting = settings.find( const fieldSetting = settings.find(
setting => setting.key === "field" && setting.type.startsWith("field/") setting => setting.key === "field" && setting.type.startsWith("field/")
) )
if (fieldSetting && component.field) { if (fieldSetting) {
const type = fieldSetting.type.split("field/")[1] const type = fieldSetting.type.split("field/")[1]
if (type) { const key = component.field || component._instanceName
schema[component.field] = { type } if (type && key) {
schema[key] = { type }
} }
} }
component._children?.forEach(child => { component._children?.forEach(child => {

View File

@ -3105,8 +3105,7 @@
{ {
"type": "field/string", "type": "field/string",
"label": "Field", "label": "Field",
"key": "field", "key": "field"
"required": true
}, },
{ {
"type": "text", "type": "text",
@ -3524,8 +3523,7 @@
{ {
"type": "field/options", "type": "field/options",
"label": "Field", "label": "Field",
"key": "field", "key": "field"
"required": true
}, },
{ {
"type": "text", "type": "text",

View File

@ -35,7 +35,7 @@
$: formStep = formStepContext ? $formStepContext || 1 : 1 $: formStep = formStepContext ? $formStepContext || 1 : 1
$: formField = formApi?.registerField( $: formField = formApi?.registerField(
field, field || $component.name,
type, type,
defaultValue, defaultValue,
disabled, disabled,