final-form-set-field-data
v1.0.2
Published
Mutator for setting arbitrary metadata on fields in ๐ Final Form
Downloads
102,677
Readme
๐ Final Form Set Field Data
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