question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

initialValues in TabbedForm within <Edit> not called

See original GitHub issue

What 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
etienne-bondotcommented, Dec 18, 2020

OK so we can use the initialValue but if the record’s source exists it will override it. Is that right ? Thank you for these information 👍

0reactions
etienne-bondotcommented, Dec 18, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set intialValues of an Edit view Form · Issue #5582 - GitHub
I'm expecting override the initialValues of the Edit form. What happened instead: There is no initialValues which is equals to the current ...
Read more >
initialValues does not get update when updating the form
I have a form called Client which has a single form which handles both add and edit . Add is working but when...
Read more >
React-admin - The Create and Edit Views
To define default values, you can add a initialValues prop to form components ( <SimpleForm> , <TabbedForm> , etc.), or add a defaultValue...
Read more >
Introduction to Application Builder - COMSOL
Use the Method editor to write methods for actions not covered by the standard use of the model tree nodes. A method is...
Read more >
Configuration Case Study. Library application. - Aware IM
An item is kept in one of the well-known locations (usually inside a library but ... retained by the library but are not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found