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 textstring—Yes
valueOption valueany—Yes
classNameCustom classstring—No
styleCustom stylestring | CSSProperties—No
disabledWhether disabledboolean—No

BaseDyFormItem ​

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

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)string—No
hiddenWhether to hide this itembooleanfalseNo
render2Custom render function (returns ReactNode)(formItem: DyFormItem) => ReactNode—No
ruleValidation rule for this item (the exact type depends on the UI layer, such as Naive UI's FormItemRule)RuleT—No
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")number—No
labelFieldMapping for the label field name in optionsstring—No
valueFieldMapping for the value field name in optionsstring—No
childFieldMapping for the child field name in optionsstring—No
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[].