serialize()

Specification

Performs a manual serialization of the current Form.

Definition

type Serialize = () => Object<fieldName, fieldValue>

Example

import React from 'react'
import { Form } from 'react-advanced-form'
import { Input } from 'react-advanced-form-addons'

export default class Example extends React.Component {
  handleButtonClick = () => {
    this.form.serialize() // { "username": "admin" }
  }

  render() {
    return (
      <div>
        <Form ref={form => this.form = form}>
          <Input
            name="username"
            value="admin" />
        </Form>
        <button onClick={this.handleButtonClick}>Serialize</button>
      </div>
    )
  }
}

You can use onSerialize form prop to transform the serialized fields object.

Last updated