Form component for rendering arrays of editable data.
<RepeatableField
addLabel="+ Add author"
fields={fields}
onAdd={this.handleAdd}
onRemove={this.handleRemove}
renderField={() => (
<TextField
label="Author"
name="author"
/>
)}
/>
<FieldArray
addLabel="+ Add author"
component={RepeatableField}
name="authors"
renderField={(field, index) => (
<Field
component={TextField}
label="Name"
name={`name[${index}]`}
/>
)}
/>
Name | type | description | default | required |
---|---|---|---|---|
addLabel | string | Text for add field row button | ||
emptyMessage | string | Text for when there are no rows; can be left blank | ||
fields | array or object | Values that go with field rows | ✔ | |
legend | node or string | Legend text that accompanies the fieldset; can be left blank | ||
onAdd | func | Callback fired when the add button is clicked | ✔ | |
onRemove | func | Callback fired when the remove row button is clicked | ✔ | |
renderField | func | Render function for each field row | ✔ |