How to use ArrayInput to populate data in react-admin list view

465 Views Asked by At

I have a react-admin Create View that I want to display and populate using ArrayInput which however seems to ignore the data of the list.

I tried to load the data with

const { data } = useQueryWithStore({
    type: 'getList',
    resource: 'comments',
});

and to set the source to it manually, but the ArrayInput seems unimpressed by all efforts to feed it some data.

I can iterate through the data array and render TextFields and remove buttons accordingly, while leaving the ArrayInput for adding new data, but that defeats the purpose and the beautiful interaction with ArrayInput. Is there something I'm missing? How should I pass the data for it to work as one would expect? I made a sandbox example for this HERE

1

There are 1 best solutions below

0
On

For creating multiple rows of the entity with one form submit you will need a custom implementation or a work-around.

One of the most esiest ways could be to handle manually the submission of the form and alter the data and send separate requests for each entered entity.

Here in the docs is shown an example how you can pass the Create view a custom toolbar where you can implement your logic.