Skip to content

Mutator for setting arbitrary metadata on fields in 🏁 Final Form

License

Notifications You must be signed in to change notification settings

final-form/final-form-set-field-data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

5daa282 Β· Sep 24, 2019

History

9 Commits
Sep 24, 2019
Feb 7, 2019
Feb 7, 2019
Dec 5, 2017
Dec 5, 2017
Feb 7, 2019
Dec 5, 2017
Dec 5, 2017
Dec 5, 2017
Dec 5, 2017
Dec 6, 2017
Feb 7, 2019
Dec 5, 2017
Feb 7, 2019
Feb 7, 2019

Repository files navigation

🏁 Final Form Set Field Data

NPM Version NPM Downloads Build Status codecov.io styled with prettier

Mutator for setting arbitrary metadata for fields in 🏁 Final Form.


Installation

npm install --save final-form-set-field-data

or

yarn add final-form-set-field-data

Usage

import { createForm } from 'final-form'
import setFieldData from 'final-form-set-field-data'

// Create Form
const form = createForm({
  mutators: { setFieldData },
  onSubmit
})

form.mutators.setFieldData('firstName', { awesome: true })

form.registerField(
  'firstName',
  fieldState => {
    const { awesome } = fieldState.data // true
  },
  {
    // ...other subscription items
    data: true
  }
)

Mutator

form.mutators.setFieldData(name: string, values: Object) => void

Merges the values provided into the data value for the specified field