score:6

Accepted answer

In order to access the FieldArray dynamically, you would want to change this:

change("FieldArraysForm", `${props.member}.firstName`, this.props.hasLastName)

to this:

change("FieldArraysForm", `members[${this.props.index}].firstName`, this.props.hasLastName)

Also, pass in the form selector specified:

const selector = formValueSelector("fieldArrays");

This would give you:

change("fieldArrays", `members[${this.props.index}].firstName`, this.props.hasLastName)

Had to get some help on this one - thanks goes to @Amanda Field.

score:5

You need to specify the index of the field in FieldArray you want to change. To do so, just use <fieldName>.<index>.<propertyName>, for instance:

this.props.change('members.0.firstName', 'Donald')

where member is the name of your FieldArray field, 0 is the index of the item in the array you want to change and firstName is the property of the object. See sandbox here


Related Query

More Query from same tag