React-admin: ArrayInput component

Created on 19 Nov 2019  路  3Comments  路  Source: marmelab/react-admin

What you were expecting:
I have a params array that stores strings as array values. Expected to input array values into a blank edit form while clicking +(add) button.

What happened instead:
[object object] is shown instead of blank space on clicking +(Add) button of simpleformiterator

Related code:

<ArrayInput source="params" >
          <SimpleFormIterator>
            <TextInput />
          </SimpleFormIterator>
        </ArrayInput>

Other information:
We have params from the backend of the following pattern: "params":["hey","iiiih","new ","test1","test2"] while trying to add new value to params array [object Object] is shown

arrayinputcomponent

Environment

while creating a new array this is how it is shown
arrayinput

@fzaninotto

  • Stack trace (in case of a JS error):

Most helpful comment

I also struggled with this and I had to create my own form iterator. [object Object] is a stringified empty object, pushed on line 108 in SimpleFormIterator.js. You can replace it with an empty string, that should solve your issue.

https://github.com/marmelab/react-admin/blob/c658516267764fe213ef133cfa40a975b21a90d1/packages/ra-ui-materialui/src/form/SimpleFormIterator.js#L105-L109

I wish SimpleFormIterator accepted a defaultFieldValue prop instead of the hard coded {}.

All 3 comments

I think it's a duplicate of #3249

I also struggled with this and I had to create my own form iterator. [object Object] is a stringified empty object, pushed on line 108 in SimpleFormIterator.js. You can replace it with an empty string, that should solve your issue.

https://github.com/marmelab/react-admin/blob/c658516267764fe213ef133cfa40a975b21a90d1/packages/ra-ui-materialui/src/form/SimpleFormIterator.js#L105-L109

I wish SimpleFormIterator accepted a defaultFieldValue prop instead of the hard coded {}.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

waynebloss picture waynebloss  路  3Comments

nicgirault picture nicgirault  路  3Comments

kdabir picture kdabir  路  3Comments

phacks picture phacks  路  3Comments

samanmohamadi picture samanmohamadi  路  3Comments