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
commit c33741a5e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 1 deletions

View file

@ -47,7 +47,22 @@ const EndpointModal: FC<Props> = ({
return
}
}
onSaved(tempCredential)
// Fix: Process boolean fields to ensure they are sent as proper boolean values
const processedCredential = { ...tempCredential }
formSchemas.forEach((field) => {
if (field.type === 'boolean' && processedCredential[field.name] !== undefined) {
const value = processedCredential[field.name]
if (typeof value === 'string')
processedCredential[field.name] = value === 'true' || value === '1' || value === 'True'
else if (typeof value === 'number')
processedCredential[field.name] = value === 1
else if (typeof value === 'boolean')
processedCredential[field.name] = value
}
})
onSaved(processedCredential)
}
return (