Skip to content

Latest commit

 

History

History
45 lines (42 loc) · 1.13 KB

File metadata and controls

45 lines (42 loc) · 1.13 KB

RepeatableField

Form component for rendering arrays of editable data.

Usage

<RepeatableField
  addLabel="+ Add author"
  fields={fields}
  onAdd={this.handleAdd}
  onRemove={this.handleRemove}
  renderField={() => (
    <TextField
      label="Author"
      name="author"
    />
  )}
/>

With Redux Form

<FieldArray
  addLabel="+ Add author"
  component={RepeatableField}
  name="authors"
  renderField={(field, index) => (
    <Field
      component={TextField}
      label="Name"
      name={`name[${index}]`}
    />
  )}
/>

Props

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