The default value of an ArrayInput doesn't work with a SimpleFormIterator
See original GitHub issueWhat you were expecting:
I want to have a default value for an ArrayInput
with a SimpleFormIterator
as a child.
What happened instead: The input isn’t populated as expected and stay empty.
Steps to reproduce:
- Have an
ArrayInput
with aSimpleFormIterator
as a child - Set the prop
defaultValue
with a correct format
Related code:
See the first input in src/posts/PostCreate.js
file within the following Code Sandbox:
https://codesandbox.io/s/1wqxkv6pml
The code is the following:
<ArrayInput
source="backlinks"
defautltValue={[
{ date: "2012-08-09T00:00:00.000Z", url: "http://example.com/bar/baz.html" }
]}
>
<SimpleFormIterator>
<DateInput source="date" />
<TextInput source="url" />
</SimpleFormIterator>
</ArrayInput>
Other information: Related question on SO: https://stackoverflow.com/questions/51425225/arrayinput-how-to-set-default-value
Environment
- React-admin version: from 2.0.2 to 2.1.2 at least
- React version: 16.3.1
- Browser: Chrome
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
react admin - ArrayInput - How to set default value
I reproduced the issue in a CodeSandbox and I filled an issue for you: CodeSandbox: See the field backlinks in the src/posts/PostCreate file...
Read more >The ArrayInput Component - React-admin - Marmelab
Default value of each is false . import { ArrayInput, SimpleFormIterator, DateInput, TextInput } from 'react-admin'; <ArrayInput source="backlinks"> ...
Read more >How to use the react-admin.minValue function in react ... - Snyk
To help you get started, we've selected a few react-admin. ... Use Snyk Code to scan source code in minutes - no build...
Read more >Simple_Form Default Value Is Not Been Displayed. - ADocLib
... The default value of an ArrayInput doesn't work with a SimpleFormIterator hot 21. Select input and Reference input not working correctly hot...
Read more >REACT-ADMIN Framework, DefaultValue (InitialValue) for a ...
I think I've tried every combination I can to get and set the default or initial value for a SelectInput. But nothing seems...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@afilp I have same problem on v3.7.2. I just want to show 4 blank inputs on load.
@Kmaschta @fzaninotto I also believe there is a bug here, in my case I get hundreds of re-rerenderings and the app crashes with the following errors:
Note: Not sure if this is the reason, I have the
ArrayInput
in the return function of aQuery
, could this cause any problems? If I comments out thedefaultValue
everything works as expected, but when I include it then I get the above errors (which make the app halt).