setErrors()
Definition
type SetErrors = (fieldsDelta: FieldsDelta) => Object
type Errors = string[] | string | null
type FieldsDelta = {
[fieldName?]: Errors | FieldsDelta,
}Examples
On submit failure
import React from 'react'
import { Form, Field } from 'react-advanced-form'
import { Input } from 'react-advanced-form-addons'
export default class Example extends React.Component {
handleRegisterFailure = ({ res, form }) => {
const { errors } = res
form.setErrors({
username: errors.username,
billingAddress: {
firstName: errors.firstName,
},
})
}
render() {
return (
<Form onSubmitFailed={this.handleRegisterFailure}>
<Input
name="username"
required />
<Field.Group name="billingAddress">
<Input
name="firstName"
required />
</Field.Group>
</Form>
)
}
}Form reference
Last updated