Skip to main content

Usage

Form

Form is a wrapper for inner component and it should co-work with inner Field.

  • props
PropertyDescriptionTypeDefault
onFinishcallback when form is submitted and rules validation passedfunction-
onFinishFailedcallback when form is submitted and rules validation failedfunction-
initialValuesinitla values for form fieldany-
tip

We must put an Button widget with action submit in the form to trigger the action of submit.

<Form
onFinish={(values: any) => {
console.log(`values = `, values);
}}
onFinishFailed={({errors, values}: {errors: any, values: any}) => {
console.log(`errors = `, errors);
console.log(`values = `, values);
}}
initialValues={{
input: '123',
}}
>
<Field label="Input" name="input" rule={{type: 'string', required: true}}>
<Input />
</Field>
<Button.FWButton text='click' action='submit'/>
</Form>

form

Field

A wrapper for Element, it can be used with Form or without Form individually.
The feature of Field is to provide label, help, extra, validateStatus, rules, etc.

  • props
PropertyDescriptionTypeDefault
namefor Form to identify each elementstring-
labelshow the label for each elementstring-
validateStatusshow different status of elementsuccess | error | warning-
helpshow error message for element, co-work with validateStatusstring-
extrashow extra description for elementstring-
rulerule for async-validator to validate the fieldrule-
childreninner element, can only be on childReactNode-
valuePropsNamethe prorps name for retrieving valuestringvalue
onChangePropsNamethe props name for callback of value changestringonChange
eventPropsNamethe props name for lodash to retriving value from eventstring-
<Field label="Input" name="input" validateStaus='error' help='invalid input'>
<Input />
</Field>

field