getValues

Returns the current values of the form fields or a field array.

// Get values of each field
const values = getValues(form, options);

// Get values of a field array
const values = getValues(form, name, options);

// Get values of specific fields
const values = getValues(form, names, options);

Parameters

  • form FormStore
  • names string
  • names string[]
  • options object = {}
    • shouldActive boolean = true
    • shouldTouched boolean = false
    • shouldDirty boolean = false
    • shouldValid boolean = false

Explanation

Besides the names of fields, you can also specify the name of a field array under names to get the value of each contained field.

By default, only the values of fields that are currently active are returned. If you want values of inactive fields to be returned as well, you can set shouldActive to false.

By default, the values of fields that are not touched, not dirty and not valid are also returned. If you want only the values of the touched, dirty and/or valid fields to be returned, you can set shouldTouched, shouldDirty and/or shouldValid to true.

shouldActive, shouldTouched, shouldDirty and shouldValid act like a kind of filter and can be combined with each other.

Return