Mutator for setting arbitrary metadata on fields in 🏁 Final Form
Switch branches/tags
Nothing to show
Clone or download
Latest commit 2f4a534 Jan 11, 2018
Permalink
Failed to load latest commit information.
.github Fix links to repo (#1) Dec 5, 2017
src v1.0.1 Jan 10, 2018
.babelrc First commit Dec 5, 2017
.eslintignore First commit Dec 5, 2017
.eslintrc First commit Dec 5, 2017
.flowconfig First commit Dec 5, 2017
.gitignore First commit Dec 5, 2017
.prettierrc First commit Dec 5, 2017
.travis.yml First commit Dec 5, 2017
LICENSE First commit Dec 5, 2017
README.md Fixed travis badge Dec 6, 2017
package-lock.json v1.0.1 Jan 10, 2018
package-scripts.js First commit Dec 5, 2017
package.json v1.0.1 Jan 10, 2018
rollup.config.js First commit Dec 5, 2017

README.md

🏁 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