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(
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 => {

View File

@ -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",

View File

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