Skip to main content

表单项(字典) FormComponents

FormComponents 是一个通用的根据字典(1:男 2:女)数据 渲染的表单的实用组件。它会根据传入的 type 类型动态选择对应的表单组件(如下拉框、单选框或复选框),并传入相应的属性和数据源。

它的设计目的是在表单中通过统一的方式使用不同的输入控件,便于组件复用与配置化。


📦 引入方式

import { FormComponents } from '@npmqg/react-ui-formcomponents';

🧩 使用示例

// SystemUserStatus 为预定义的字典
<FormComponents init="SystemUserStatus" type="select" />

// 在表单中使用
<FormField
control={form.control}
name="status"
render={({ field }) => (
<FormItem>
<FormLabel>{Intl.v('状态')}</FormLabel>
<FormControl>
<FormComponents init="SystemUserStatus" type="select" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>

🧩 支持的表单组件类型

组件支持以下 type 类型:

类型值渲染组件
select下拉选择框组件
radio单选框组件
checkbox复选框组件