Form consists of
input,radio,select,checkboxand so on. With form, you can collect, verify and submit data
Tip
Applicable to any component that can bind value through v-model. example:
el-input el-switch input …el-upload … (The relevant components need to be rewritten to support v-model components)When columns is bound to a reactive array, changes in the array will affect form changes (dynamic form). If you don’t need a dynamic form, it is recommended to bind an ordinary array.
Use the defineFormColumns defineFormMenuColumns defineFormSubmit defineComponentProps to make it easier to define columns
Support for set the objects or arrays with nested structures value, only need to configure the prop
{}
Set component in columns attribute to dfine what component the item generates, that component should can bind value through v-model. props can be passed to the component through props, render-function can be passed to the component thrrough slots in props
Local component can be passed directly through component in columns attribute (marking the component with markRaw)
By default, the ProForm component only supports components that bind values through v-model. If you need to use other arguments to bind values, you can configure it through models. When models is specified, the prop attribute will be ignored (the binding implemented by v-model will be invalid), and you need to pass { prop: [prop], key: 'modelValue' } to models to implement the binding.
In addition, models can also be used to bind multiple parameters to a component
TIP
Since 1.4.0, the modelKey attribute has been deprecated, please use the models attribute instead
TIP
Since 1.4.1, support binding component instances through ref
Tip
Starting from 1.2.0, the [prop] related slots need to be prefixed with form- to use
Directly add some slot with form-[prop] in the template
Set menu attribute to enable custom menu
Menu can also be configured through Localization
Set children in columns attribute to enable custom sub-forms
Set rules attribute to enable validation, or Set rules in columns attribute to enable validation, or reference ${parental prop}.${current index}.${current prop}
If the columns with reactive, the dynamically modified columns form will also change accordingly
By controlling the show field of columns, the display of the form can be dynamically controlled, making it easy to achieve linked forms
Use the same way as el-row el-col (el-row corresponds to pro-form; el-col corresponds to columns) Invalid when inline is true
Set the inline attribute to true and the form will be inline
The label-position attribute decides how labels align
The array form is the same as the sub-form. It is used to handle the situation where an array needs to be entered. Just configure the array to enable
The Group Form used to display ordinary forms in groups
Collapsible group form
Switch different forms through tabs
Split a form into several steps for input
To implement Async Form, columns must be bound to a reactive array
The function defineFormColumns supports passing in a Generics type to infer the value of prop, The function defineComponentProps supports passing in a Generics type to help input the props value
| Name | Description | Type | Options | Default | 
|---|---|---|---|---|
| v-model | binding value | object / array | - | - | 
| columns | to generate form components, reference columns | array | - | - | 
| menu | config the menu content, reference menu | object | - | - | 
| rules | validation rules of form | object | - | - | 
| inline | whether the form is inline | boolean | - | false | 
| array | whether the form is ArrayForm | boolean | - | |
| max | limit the maximum number of ArrayForm component | number | - | - | 
| label-position | position of label. If set to ‘left’ or ‘right’, label-widthprop is also required | string | right / left / top | right | 
| label-width | width of label, e.g. ‘50px’. All its direct child form items will inherit this value. Width autois supported. | string | - | - | 
| label-suffix | suffix of the label | string | - | - | 
| hide-required-asterisk | whether required fields should have a red asterisk (star) beside their labels | boolean | - | false | 
| show-message | whether to show the error message | boolean | - | true | 
| inline-message | whether to display the error message inline with the form item | boolean | - | false | 
| status-icon | whether to display an icon indicating the validation result | boolean | - | false | 
| validate-on-rule-change | whether to trigger validation when the rulesprop is changed | boolean | - | true | 
| size | control the size of components in this form | string | large / default /small | - | 
| disabled | whether to disabled all components in this form. If set to true, it cannot be overridden by its inner components’ disabledprop | boolean | - | false | 
| scroll-to-error | When validation fails, scroll to the first error form entry | boolean | - | false | 
| scroll-into-view-options | When validation fails, it scrolls to the first error item based on the scrollIntoView option. scrollIntoView. | object / boolean | — | - | 
| gutter | grid spacing | number | - | 0 | 
| justify | horizontal alignment of flex layout | string | start / end / center / space-around / space-between / spacing-evenly | start | 
| align | vertical alignment of flex layout | string | top / middle / bottom | top | 
| Name | Description | Type | Options | Default | 
|---|---|---|---|---|
| prop | a key of v-model(unique value) | string | - | - | 
| label | label text | string | - | - | 
| component | binding component | string | - | - | 
| props | transfer propsto the current component | object | - | - | 
| models | Configure the v-modelbinding parameters of the component corresponding to the current item (Array<{ prop, key, event }>) | array | - | - | 
| children | group form or sub-form content | array | - | - | 
| type | type of children internal forms | string | array / group / tabs / collapse / steps | array | 
| max | limit the maximum number of type=array | number | - | - | 
| show | whether to show the current component | boolean | - | true | 
| labelWidth | width of label, e.g. ‘50px’. Width autois supported. | string | - | - | 
| labelPosition | Position of item label. If set to 'left'or'right',label-widthprop is also required. Default extendlabel-postionofform. | string | left / right / top | - | 
| required | whether the field is required or not, will be determined by validation rules if omitted | boolean | - | false | 
| rules | validation rules of form | object | - | - | 
| error | field error message, set its value and the field will validate error and show this message immediately | string | - | - | 
| showMessage | whether to show the error message | boolean | - | true | 
| inlineMessage | inline style validate message | boolean | - | false | 
| size | control the size of components in this form-item | string | large / default /small | - | 
| span | number of column the grid spans | number | - | 24 | 
| offset | number of spacing on the left side of the grid | number | - | 0 | 
| push | number of columns that grid moves to the right | number | - | 0 | 
| pull | number of columns that grid moves to the left | number | - | 0 | 
| xs | <768pxResponsive columns or column props object | number / object (e.g. {span: 4, offset: 4}) | - | - | 
| sm | ≥768pxResponsive columns or column props object | number / object (e.g. {span: 4, offset: 4}) | - | - | 
| md | ≥992pxResponsive columns or column props object | number / object (e.g. {span: 4, offset: 4}) | - | - | 
| lg | ≥1200pxResponsive columns or column props object | number / object (e.g. {span: 4, offset: 4}) | - | - | 
| xl | ≥1920pxResponsive columns or column props object | number / object (e.g. {span: 4, offset: 4}) | - | - | 
| disabled | whether Tab is disabled, work on type=tabsortype=collapse | boolean | — | false | 
| closable | whether Tab is closable, work on type=tabs | boolean | — | false | 
| lazy | whether Tab is lazily rendered, work on type=tabs | boolean | — | false | 
| description | step description, work on type=steps | string | — | — | 
| icon | step custom icon, work on type=steps | string / Component | — | — | 
| status | current status, work on type=steps | string | wait / process / finish / error / success | — | 
about props
The props attribute will all be passed to the component.
slots, you can pass simple render functionson[Event]. example: change -> onChange, input -> onInput1.4.1, support binding component instances through refprops: {
  ref: searchRef,
  clearable: true,
  'prefix-icon': 'el-icon-search',
  suffixIcon: 'el-icon-date',
  slots: {
    prefix: () => h('i', { className: 'el-input__icon el-icon-search' }),
    append: () => 'Search'
  },
  onChange: e => console.log(e),
}
| Name | Description | Type | Default | 
|---|---|---|---|
| submit | whether to display a submit button | boolean | true | 
| submitText | the text of submit button | string | Submit | 
| submitProps | the props of submit button, reference el-button | object | { type: ‘primary’ } | 
| reset | Whether to display a reset button | boolean | true | 
| resetText | the text of reset button | string | Reset | 
| resetProps | the props of reset button, reference el-button | object | - | 
| prevText | the text of prev button | string | Prev | 
| prevProps | the props of prev button, reference el-button | object | - | 
| nextText | the text of next button | string | Next | 
| nextProps | the props of next button, reference el-button | object | - | 
| Name | Description | Type | 
|---|---|---|
| submit | triggers when the submit click | (done: () => void, isValid: boolean, invalidFields) => void | 
| reset | triggers when the reset click | () => void | 
| validate | triggers after a form item is validated | (prop: FormItemProp, isValid: boolean, message: string) => void | 
| add-item | triggers when the add click | (indexes: number[]) => void | 
| remove-item | triggers when the remove click | (indexes: number[]) => void | 
| collapse-change | triggers when the collapse change | (active: CollapseModelValue) => void | 
| tab-change | triggers when the tab change | (name: TabPaneName) => void | 
| step-change | triggers when the step change | (active: string | number) => void | 
| Name | Description | Type | 
|---|---|---|
| validate | validate the whole form. Takes a callback as a param. After validation, the callback will be executed with two params: a boolean indicating if the validation has passed, and an object containing all fields that fail the validation. Returns a promise if callback is omitted | (callback?: FormValidateCallback) => void | 
| validateField | validate one or several form items | (props?: string | string[], callback?: FormValidateCallback) => FormValidationResult | 
| resetFields | reset all the fields and remove validation result | (props?: string | string[]) => void | 
| scrollToField | Scroll to the specified form field | (prop: string) => void | 
| clearValidate | clear validation message for certain fields. The parameter is prop name or an array of prop names of the form items whose validation messages will be removed. When omitted, all fields’ validation messages will be cleared | (props?: string | string[]) => void | 
| Name | Description | Type | 
|---|---|---|
| - | anything inserted before the menu | - | 
| menu-left | control the menu left display content | { loading: boolean } | 
| menu-right | control the menu right display content | { loading: boolean } | 
| form-[prop] | control the Itemdisplay content | { item: object, indexes?: number[], value: any, setValue: (value: any) => void } | 
| form-[prop]-label | control the Itemlabel display content | { item: object, indexes?: number[] } | 
| form-[prop]-error | control the Itemerror display content | { error, item: object, indexes?: number[] } | 
Tip
[prop] the prop of columns