Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

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

Tianyi Jing414ee5197518
diff --git a/web/app/components/base/form/components/base/base-field.tsx b/web/app/components/base/form/components/base/base-field.tsx
index 4005bab6bc6..35ca251a5b2 100644
--- a/web/app/components/base/form/components/base/base-field.tsx
+++ b/web/app/components/base/form/components/base/base-field.tsx
@@ -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
diff --git a/web/app/components/base/form/types.ts b/web/app/components/base/form/types.ts
index f4437948f3a..90af1abe4e5 100644
--- a/web/app/components/base/form/types.ts
+++ b/web/app/components/base/form/types.ts
@@ -32,6 +32,7 @@ export enum FormTypeEnum {
multiToolSelector = 'array[tools]',
appSelector = 'app-selector',
dynamicSelect = 'dynamic-select',
+ boolean = 'boolean',
}
export type FormOption = {