Skip to content
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

Prefilled Create form is not working with URL parameters #4300

Closed
nicgirault opened this issue Jan 16, 2020 · 1 comment · Fixed by #4301
Closed

Prefilled Create form is not working with URL parameters #4300

nicgirault opened this issue Jan 16, 2020 · 1 comment · Fixed by #4301

Comments

@nicgirault
Copy link
Contributor

nicgirault commented Jan 16, 2020

What you were expecting:

According to the doc of version 3.1.2 https://marmelab.com/react-admin/CreateEdit.html:

image

What happened instead:

But in this sandbox https://codesandbox.io/s/simple-demo-882rq we can see that the form is not filled when clicking on the create button.

Other information:

I need to use URL params and not location state because I need a link to share with prefilled form.
It seems related to this part of the code: https://github.com/marmelab/react-admin/blob/master/packages/ra-core/src/controller/useCreateController.ts#L157

Environment

  • React-admin version: 3.1.2
  • React version: 16.12
@nicgirault
Copy link
Contributor Author

So actually the doc is outdated. It should look like something like this:

<Button
        color="primary"
        component={Link}
        to={{
          pathname: `/content-records/create`,
          search: `?source=${JSON.stringify({
            title: 'test',
          })}`,
        }}
      >
        Create
      </Button>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant