fix: add missing form for boolean types (#24812)

Signed-off-by: jingfelix <jingfelix@outlook.com>
This commit is contained in:
Tianyi Jing
2025-09-01 15:21:36 +08:00
committed by GitHub
parent d5a521eef2
commit 414ee51975
2 changed files with 20 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ import PureSelect from '@/app/components/base/select/pure'
import type { FormSchema } from '@/app/components/base/form/types'
import { FormTypeEnum } from '@/app/components/base/form/types'
import { useRenderI18nObject } from '@/hooks/use-i18n'
import Radio from '@/app/components/base/radio'
import RadioE from '@/app/components/base/radio/ui'
export type BaseFieldProps = {
@@ -102,6 +103,12 @@ const BaseField = ({
})
}, [values, show_on])
const booleanRadioValue = useMemo(() => {
if (value === null || value === undefined)
return undefined
return value ? 1 : 0
}, [value])
if (!show)
return null
@@ -204,6 +211,18 @@ const BaseField = ({
</div>
)
}
{
formSchema.type === FormTypeEnum.boolean && (
<Radio.Group
className='flex w-fit items-center'
value={booleanRadioValue}
onChange={val => field.handleChange(val === 1)}
>
<Radio value={1} className='!mr-1'>True</Radio>
<Radio value={0}>False</Radio>
</Radio.Group>
)
}
{
formSchema.url && (
<a

View File

@@ -32,6 +32,7 @@ export enum FormTypeEnum {
multiToolSelector = 'array[tools]',
appSelector = 'app-selector',
dynamicSelect = 'dynamic-select',
boolean = 'boolean',
}
export type FormOption = {