-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
defaultValue of Inputs inside ArrayInput not working #2489
Comments
Confirmed and reproduced. That's because // in ra-core/form/getDefaultValues.js
const getDefaultValues = (data = {}, defaultValue = {}, defaultValues = {}) => {
const globalDefaultValue =
typeof defaultValue === 'function' ? defaultValue() : defaultValue;
return { ...globalDefaultValue, ...defaultValues, ...data };
}; Let's say a record has sub elements, as follows:
Given there is an <ArrayInput>
<SimpleFormIterator>
<TextInput source="bar" defaultValue="hello" />
</SimpleFormIterator>
</ArrayInput> When a user add a
but since |
@fzaninotto So is this an issue that we should raise in |
react-admin does its own default value voodoo to overcome the redux-form limitations in this field. the solution must be found in react-admin. |
One point to add - I found that it's not working on Edit view, but works on Create page. But works only on first element in list) |
We're experiencing issues with default value of NumberInput and TextInput inside ArrayInput and SimpleFormIterator, we're on version 2.8.1 of react-admin. The default values work the first time you add a record, but default value doesn't show for subsequent record. Any updates on when this issue will be resolved? |
It might be fixed in v3 as we migrate from redux-form to react-final-form. I'll check when I'll have the time |
ping @djhi |
can we get a status update on this? I don't currently see this ticket in the v3 roadmap. |
@nosequeldeebee I found this fixed till 3.0.0-alpha.2 |
Still happening to me on v3.1.2 <ArrayInput source="tags">
<SimpleFormIterator>
<TextInput label="Tag" />
</SimpleFormIterator>
</ArrayInput> is there a way to fix it?, it keeps adding [object Object] as default value (to reproduce it you have to omit Environment
Thank you! |
Any solution on this? |
… TextInput without source param. marmelab#2489
I just did a fix for my issue #4306 , it's related to this bug, but it's not 100% this bug, please give me your feedback and see if we could fix this issue. Thanks! |
A simple workaround () for now while awaiting the above fix to be merged is to format the source as below
|
Issues are fixed in #4394 |
What you were expecting:
I set defaultValue of Inputs inside an ArrayInput and expect that when I add a new element it sets the default value. For example, if I have an array of posts each one with and id, title, created_at, description, and set the defaultValue of created_at DateInput to Date.now(), I expect that everytime I add a new post the created_at will be Date.now()
What happened instead:
It doesn't work
Related code:
Forked from simple demo, edit a post and try to add a new backlink in the miscellaneous tab.
https://codesandbox.io/s/k06x14xy8v
Environment
The text was updated successfully, but these errors were encountered: