fix: add missing form for boolean types (#24812)
Signed-off-by: jingfelix <jingfelix@outlook.com>
This commit is contained in:
@@ -12,6 +12,7 @@ import PureSelect from '@/app/components/base/select/pure'
|
|||||||
import type { FormSchema } from '@/app/components/base/form/types'
|
import type { FormSchema } from '@/app/components/base/form/types'
|
||||||
import { FormTypeEnum } from '@/app/components/base/form/types'
|
import { FormTypeEnum } from '@/app/components/base/form/types'
|
||||||
import { useRenderI18nObject } from '@/hooks/use-i18n'
|
import { useRenderI18nObject } from '@/hooks/use-i18n'
|
||||||
|
import Radio from '@/app/components/base/radio'
|
||||||
import RadioE from '@/app/components/base/radio/ui'
|
import RadioE from '@/app/components/base/radio/ui'
|
||||||
|
|
||||||
export type BaseFieldProps = {
|
export type BaseFieldProps = {
|
||||||
@@ -102,6 +103,12 @@ const BaseField = ({
|
|||||||
})
|
})
|
||||||
}, [values, show_on])
|
}, [values, show_on])
|
||||||
|
|
||||||
|
const booleanRadioValue = useMemo(() => {
|
||||||
|
if (value === null || value === undefined)
|
||||||
|
return undefined
|
||||||
|
return value ? 1 : 0
|
||||||
|
}, [value])
|
||||||
|
|
||||||
if (!show)
|
if (!show)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
@@ -204,6 +211,18 @@ const BaseField = ({
|
|||||||
</div>
|
</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 && (
|
formSchema.url && (
|
||||||
<a
|
<a
|
||||||
|
@@ -32,6 +32,7 @@ export enum FormTypeEnum {
|
|||||||
multiToolSelector = 'array[tools]',
|
multiToolSelector = 'array[tools]',
|
||||||
appSelector = 'app-selector',
|
appSelector = 'app-selector',
|
||||||
dynamicSelect = 'dynamic-select',
|
dynamicSelect = 'dynamic-select',
|
||||||
|
boolean = 'boolean',
|
||||||
}
|
}
|
||||||
|
|
||||||
export type FormOption = {
|
export type FormOption = {
|
||||||
|
Reference in New Issue
Block a user