initialValues in TabbedForm within <Edit> not called
See original GitHub issueWhat you were expecting:
My use case is one where I need to do some data transformation upon calling the provider GET APIs before they get rendered in my <Create>
/ <Edit>
views. From https://marmelab.com/react-admin/CreateEdit.html#default-values my understanding is that the initialValues
attribute can be used under <TabbedForm>
under both <Create>
and <Edit>
. Under my <Create>
it correctly fires and my expectation is that under <Edit>
it should also fire.
What happened instead:
When placed as an attribute in <TabbedForm>
under <Edit>
it does not fire the actual call to my function referenced by initialValues
.
Steps to reproduce:
Add an initialValues
attribute pointing to a function, for a <TabbedForm>
under <Edit>
and notice that entering into the Edit view that the function is not called.
Related code:
const postDefaultValue = () => ({ created_at: new Date(), weight: 915 });
export const HbEventEdit = props => (
<Edit {...props} transform={updateUrl}>
<TabbedForm initialValues={postDefaultValue}>
...
</TabbedForm>
</Edit>
);
Other information:
Environment
- React-admin version: 3.10.3
- Last version that did not exhibit the issue (if applicable): N/A
- React version: 16.13.1
- Browser: Chrome Version 87.0.4280.88 (Official Build) (64-bit)
- Stack trace (in case of a JS error):
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:12 (3 by maintainers)
Top GitHub Comments
OK so we can use the
initialValue
but if the record’ssource
exists it will override it. Is that right ? Thank you for these information 👍I personally can’t made a complexe switch base on the resource within my customDataProvider. I will keep the mapping within the form top level.