Skip to content

Array Component

In FormCreate, sub-form functionality can be easily implemented through the group component. Sub-form components allow nesting other forms within forms, suitable for handling repetitive form content, such as dynamically adding contacts, product specifications, and other scenarios.

Note

Component linkage within sub-forms is recommended to be implemented using Component Linkage or Computing Component Rules.

When operating components within sub-forms, you need to use the sub-form's API. In the parent form, you can get the operation interface of the specified sub-form through the api.getSubForm method.

Basic Sub-form

Shows a simple sub-form where users can dynamically add and remove form items.

Card Style

Sub-forms added card style in v3.2.31 version

Sub-form with Specified Field

This example shows how to only get the value of a specific field in the sub-form.

Computing Component Display State in Sub-form

Based on the main form radio button's value (show or hide), calculate and set the sub-form input box's hidden property in real-time to achieve cross-level conditional display control.

Listening to Component Events in Sub-form

This example shows how to listen to component events in sub-forms.

Configuration

props

Parameter NameDescriptionTypeDefault Value
rule (Required)Generation rules for nested componentsRule[]-
fieldOnly get this field in sub-formString-
type(v3.2.31)Component display style'default' | 'card'-
expandNumber of sub-forms expanded by defaultNumber-
optionsSub-form option configurationObject-
buttonWhether to show operation buttonsBoolean-
maxMaximum number of items to addNumber-
minMinimum number of items to addNumber0
modelValue (v-model)Sub-form valueany[]-
defaultValueSet default value for new sub-formsObject-
sortBtnWhether to show sort adjustment buttonBooleantrue
disabledWhether disabledBooleanfalse
onBeforeRemovePre-callback when deleting, cancel operation when returning false(value: any[], index: number) => boolean|Promise|undefined-
onBeforeAddPre-callback when adding, cancel operation when returning false(value: any[]) => boolean|undefined-
parseModify form rules before sub-form creation(rule:Rule[])=>Rule[]-

events

Event NameDescriptionReturn Value
changeTriggered after value changes-
addTriggered after adding an item-
removeTriggered after removing an item-
itemMountedTriggered after newly added sub-form initialization is complete-
[field-eventName]Listen to sub-form emit events, format is sub-form field name concatenated with event name-

FormCreate is an open-source project released under the MIT License. Free for personal and commercial use.