actions
Located in redux-forms/actions
, all action creators are exported for the brave. If you need a fine-grained control over your application, this is the section for you!
Note: Although all action names are exported too, my advice is to avoid relying on them as breaking changes could occur in the future. Stick to using the creators directly.
All actions that require a form/field/array name will not work if a one with the supplied name doesn't exist.
IDs
All fields have their unique string id depending on their position within the form. The id is compatible with the flat package - their path is separated with .
.
Say we have the following form:
{
name: 'Joe',
hobbies: ['cheese', 'bench', 'food'],
pets: [{
type: 'dog',
name: 'Reaper',
nicknames: ['doggo'],
}, {
type: 'cat',
name: 'Kit',
nicknames: [],
}],
}
Let's look at the ids of some of the fields:
name
is simplyname
- Index 2 of
hobbies
ishobbies.2
- Member
type
in index 1 ofpets
ispets.1.type
- Index 0 of the member
nicknames
in index 0 ofpets
ispets.0.nicknames.0
Arrays are indexed the same way:
pets
array is simplypets
nicknames
array in index 1 ofpets
ispets.1.nicknames
Form
addForm: (name: string) => Object
- Adds a new form
removeForm: (name: string) => Object
- Removes a form
addField: (form: string, id: string) => Object
- Adds a new field to a form
removeField: (form: string, id: string) => Object
- Removes a field from a form
touchAll: (form: string) => Object
- Touches all fields of a form. Useful when submitting.
submitStart: (form: string) => Object
- Marks a from as submitting
submitStop: (form: string) => Object
- Marks a from as not submitting
field
fieldChange: (
form: string,
field: string,
value: any,
error: string,
dirty: boolean,
) => Object
- Useful for
onChange
events. Changes a field'svalue
,error
anddirty
properties.
fieldFocus: (form: string, field: string) => Object
- Useful for
onFocus
events. Marks a field asactive
and sets it asvisited
.
fieldBlur: (
form: string,
field: string,
value: any,
error: string,
dirty: boolean,
) => Object
- Useful for
onBlur
events. Changes a field'svalue
,error
anddirty
properties, as well as unmarks it asactive
and sets it astouched
.
fieldValue: (form: string, field: string, value: any) => Object
- Changes the value of a field
fieldError: (form: string, field: string, error: string | null) => Object
- Changes the error of a field
fieldDirty: (form: string, field: string, dirty: boolean) => Object
- Marks the field as dirty or not
fieldArray
addArray: (form: string, id: string) => Object
- Adds a new array to a form
removeArray: (form: string, id: string) => Object
- Removes an array from a form
arrayPush: (form: string, id: string) => Object
- Pushes a new field to the end of an array
arrayPop: (form: string, id: string) => Object
- Removes the last field of an array
arrayUnshift: (form: string, id: string) => Object
- Unshifts a new field to the beginning of an array
arrayShift: (form: string, id: string) => Object
- Shifts the array, losing the first field
arrayInsert: (form: string, id: string, index: number) => Object
- Inserts a field after the specified index
arrayRemove: (form: string, id: string, index: number) => Object
- Removes a field at the specified index
arraySwap: (form: string, id: string, index1: number, index2: number) => Object
- Swaps fields at the specified indexes
arrayMove: (form: string, id: string, from: number: to: number) => Object
- Moves a field from one index to the other