Search code examples
admin-on-rest

Implementing Redux Form FieldArray in admin-on-rest


My schema has a field which is an unlimited array of textfields. I want to do exactly what the example here at the end shows: http://redux-form.com/6.5.0/docs/api/FieldArray.md

const renderSubFields = (member, index, fields) => (
    <li key={index}>
      <button
        type="button"
        title="Remove Member"
        onClick={() => fields.remove(index)}/>
      <h4>Member #{index + 1}</h4>
      <Field
        name={`${member}.firstName`}
        type="text"
        component={renderField}
        label="First Name"/>
      <Field
        name={`${member}.lastName`}
        type="text"
        component={renderField}
        label="Last Name"/>
    </li>
)
const renderMembers = ({ fields }) => (
  <ul>
    <button type="button" onClick={() => fields.push({})}>Add Member</button>
    {fields.map(renderSubFields)}
  </ul>
)

I imagine this is a fairly common thing to do but I don't see anything like this in the AOR docs or demo. Are there any examples that I'm missing?


Solution

  • I think you meant EmbeddedManyInput that desribed in https://github.com/marmelab/admin-on-rest/issues/695