1. 组件
  2. 数据录入
  3. Form 表单

Form 表单

表单用于收集和处理用户输入的数据。

Form 表单

安装

$ pnpm add @casts/form

基础案例

布局

标签对齐

Remember me

表单验证

动态表单项

API

Form

PropertyDescriptionTypeDefaultRequired
getPrefixClsclass name prefixGetPrefixCls-false
childrenContentReactNode-false
classNameClassNamestring-false
styleCustom StyleCSSProperties-false
layoutThe layout of fieldsinline | horizontal | vertical-false
labelWidthWidth of field's labelstring-false
colonWhether to display a colon to the right of the form label fieldbooleanfalsefalse
requiredWhether to show the requiredboolean-false
labelAlignText-align value of label (only works when layout="horizontal")right | left-false
onSubmitCallback invoked after clicked on submit button or executed formApi.submit(), and all validation pass.SubmitHandler<Record<string, any& gt;>-false

FormControl

PropertyDescriptionTypeDefaultRequired
getPrefixClsclass name prefixGetPrefixCls-false
childrenContentReactNode-false
classNameClassNamestring-false
styleCustom StyleCSSProperties-false
namefield namestring-false
labelfield labelstring-false
valuePropNamecomponent value propstring-false
rulesfield validate rulesValidateRule[]-false
statusfield validate statuserror | warning | success-false
helpfield help contentReactNode-false
extrafield extra contentReactNode-false

FormItem

PropertyDescriptionTypeDefaultRequired
getPrefixClsclass name prefixGetPrefixCls-false
childrenContentReactNode-false
classNameClassNamestring-false
styleCustom StyleCSSProperties-false
namefield namestring-false
labelfield labelstring-false
valuePropNamecomponent value propstring-false
rulesfield validate rulesValidateRule[]-false

FormLabel

PropertyDescriptionTypeDefaultRequired
getPrefixClsclass name prefixGetPrefixCls-false
childrenContentReactNode-false
classNameClassNamestring-false
styleCustom StyleCSSProperties-false

FormList

PropertyDescriptionTypeDefaultRequired
getPrefixClsclass name prefixGetPrefixCls-false
classNameClassNamestring-false
styleCustom StyleCSSProperties-false
namefield namestring-true

FormProvider

PropertyDescriptionTypeDefaultRequired
layoutThe layout of fieldsinline | horizontal | vertical-false
labelWidthWidth of field's labelstring-false
colonWhether to display a colon to the right of the form label fieldbooleanfalsefalse
requiredWhether to show the requiredboolean-false
labelAlignText-align value of label (only works when layout="horizontal")right | left-false
onSubmitCallback invoked after clicked on submit button or executed formApi.submit(), and all validation pass.SubmitHandler<Record<string, any>>-false

useForm

PropertyDescriptionTypeDefaultRequired
getPrefixClsclass name prefixGetPrefixCls-false
classNameClassNamestring-false
styleCustom StyleCSSProperties-false
layoutThe layout of fieldsinline | horizontal | vertical-false
labelWidthWidth of field's labelstring-false
colonWhether to display a colon to the right of the form label fieldbooleanfalsefalse
requiredWhether to show the requiredboolean-false
labelAlignText-align value of label (only works when layout="horizontal")right | left-false
onSubmitCallback invoked after clicked on submit button or executed formApi.submit(), and all validation pass.SubmitHandler<Record<string, any>>-false

useFormControl

PropertyDescriptionTypeDefaultRequired
getPrefixClsclass name prefixGetPrefixCls-false
classNameClassNamestring-false
styleCustom StyleCSSProperties-false
labelWidthWidth of field's labelstring-false
namefield namestring-false
labelfield labelstring-false
rulesfield validate rulesValidateRule[]-false
statusfield validate statuserror | warning | success-false

useFormItem

PropertyDescriptionTypeDefaultRequired
getPrefixClsclass name prefixGetPrefixCls-false
classNameClassNamestring-false
styleCustom StyleCSSProperties-false
labelWidthWidth of field's labelstring-false
namefield namestring-false
labelfield labelstring-false
rulesfield validate rulesValidateRule[]-false
statusfield validate statuserror | warning | success-false

useFormLabel

PropertyDescriptionTypeDefaultRequired
getPrefixClsclass name prefixGetPrefixCls-false
classNameClassNamestring-false
styleCustom StyleCSSProperties-false

useFormList

PropertyDescriptionTypeDefaultRequired
getPrefixClsclass name prefixGetPrefixCls-false
classNameClassNamestring-false
styleCustom StyleCSSProperties-false
namefield namestring-true