Skip to content

DyFormItem

DyFormItem is the configuration type for a single dynamic form item. Each entry in the items array passed to AdDynamicForm is a DyFormItem.

TIP

Most of the types below are similar to the props in the vue3 version.

SelectOptionItem

FieldDescriptionTypeDefaultRequired
labelDisplay textstringYes
valueOption valueanyYes
classNameCustom classstringNo
styleCustom stylestring | CSSPropertiesNo
disabledWhether disabledbooleanNo

BaseDyFormItem

FieldDescriptionTypeDefaultRequired
keyField identifier (recommended to match the form model field)keyof TYes
labelForm item labelstringNo
valueReactive value (source of form data)any, when wrapped with useReactiveForm or useDecorateForm will be wrapped automaticallyYes
placeholderPlaceholder textstringNo
optionsOption data (for select / checkbox / radio, etc.)SelectOptionItem[] | any[]No
onChangeCallback triggered when the value changes(value: any, associationItem: DyFormItem, options?: SelectOptionItem[] | any[]) => voidNo
spanGrid span (commonly used when preset="grid")numberNo
offsetGrid offset (commonly used when preset="grid")numberNo
sortSort field (used for sorting if sorting logic is enabled)numberNo

DyFormItem

DyFormItem<K, RuleT> extends BaseDyFormItem<K> and adds rendering, validation, display control, and related capabilities.

FieldDescriptionTypeDefaultRequired
pathForm validation path (defaults to key if not provided)stringNo
hiddenWhether to hide this itembooleanfalseNo
render2Custom render function (returns ReactNode)(formItem: DyFormItem) => ReactNodeNo
ruleValidation rule for this item (the exact type depends on the UI layer, such as Naive UI's FormItemRule)RuleTNo
requiredSimplified required option (if rule is not provided, a required rule can be generated automatically)booleanfalseNo
requiredHintRequired field message(label: string) => string"label" cannot be emptyNo
disabledDisabled state (supports boolean)booleanfalseNo
allowClearWhether clearing is allowedbooleanfalseNo
typeSimplified type (commonly used for input)"text" | "textarea" | "password""text"No
rowsNumber of rows for multiline input (commonly used when type="textarea")numberNo
labelFieldMapping for the label field name in optionsstringNo
valueFieldMapping for the value field name in optionsstringNo
childFieldMapping for the child field name in optionsstringNo
showSearchWhether filtering is enabled (commonly used for select components)boolean-No
searchOnLabelWhether filtering is based on the label valueboolean-No
showCountWhether to display the character countboolean-No
modeRendering mode'multiple' | 'tags'-No
isCustomWhether to use a custom validation ruleboolean-No
formItemPropsForm.Item propsobject-No

About RuleT

The rule field in DyFormItem uses the generic type RuleT to avoid binding the shared type file to a specific UI framework. For example, in the Antd module, RuleT can be bound to Rule \| Rule[].