fix: improve boolean field handling in plugin configuration forms (#23160)

Co-authored-by: crazywoola <427733928@qq.com>
This commit is contained in:
Alan Bustamante
2025-08-01 04:34:46 +02:00
committed by GitHub
parent 872ff3f1d4
commit c33741a5e9
2 changed files with 26 additions and 1 deletions

View File

@@ -63,6 +63,16 @@ export const addDefaultValue = (value: Record<string, any>, formSchemas: { varia
const itemValue = value[formSchema.variable]
if ((formSchema.default !== undefined) && (value === undefined || itemValue === null || itemValue === '' || itemValue === undefined))
newValues[formSchema.variable] = formSchema.default
// Fix: Convert boolean field values to proper boolean type
if (formSchema.type === 'boolean' && itemValue !== undefined && itemValue !== null && itemValue !== '') {
if (typeof itemValue === 'string')
newValues[formSchema.variable] = itemValue === 'true' || itemValue === '1' || itemValue === 'True'
else if (typeof itemValue === 'number')
newValues[formSchema.variable] = itemValue === 1
else if (typeof itemValue === 'boolean')
newValues[formSchema.variable] = itemValue
}
})
return newValues
}