serialize()

Specification

Performs a manual serialization of the current Form.
Invoking this manually serializes a form regardless to its validity state. This is almost never what you want. Consider using conventional form submit, which validates the fields and exposes you the serialized object.

Definition

1
type Serialize = () => Object<fieldName, fieldValue>
Copied!

Example

1
import React from 'react'
2
import { Form } from 'react-advanced-form'
3
import { Input } from 'react-advanced-form-addons'
4
5
export default class Example extends React.Component {
6
handleButtonClick = () => {
7
this.form.serialize() // { "username": "admin" }
8
}
9
10
render() {
11
return (
12
<div>
13
<Form ref={form => this.form = form}>
14
<Input
15
name="username"
16
value="admin" />
17
</Form>
18
<button onClick={this.handleButtonClick}>Serialize</button>
19
</div>
20
)
21
}
22
}
Copied!
You can use onSerialize form prop to transform the serialized fields object.
Last modified 3yr ago