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

Allow record override from location everywhere #10412

Merged
merged 17 commits into from
Dec 18, 2024

Conversation

djhi
Copy link
Collaborator

@djhi djhi commented Dec 12, 2024

Problem

There's no way to redirect to an Edit form with modifications. This makes it cumbersome to prefill an EditForm (see e.g. ra-history Revert button).

Solution

We already have a mechanism to prefill a form from the location state or search query in useCreateController that we leverage for cloning.

  • Extract this mechanism into a hook
  • Refactor it to merge the location data into a provided record
  • Use the hook in useAugmentedForm
  • Test edition with this mechanism
  • Document the useRecordFromLocation hook

How To Test

Additional Checks

  • The PR targets master for a bugfix, or next for a feature
  • The PR includes unit tests (if not possible, describe why)
  • The PR includes one or several stories (if not possible, describe why)
  • The documentation is up to date

Also, please make sure to read the contributing guidelines.

@djhi djhi added the WIP Work In Progress label Dec 12, 2024
@djhi djhi added RFR Ready For Review and removed WIP Work In Progress labels Dec 16, 2024
@slax57 slax57 self-requested a review December 17, 2024 10:18
docs/Edit.md Outdated Show resolved Hide resolved
docs/Edit.md Outdated Show resolved Hide resolved
docs/Edit.md Outdated Show resolved Hide resolved
docs/Edit.md Outdated Show resolved Hide resolved
docs/useRecordFromLocation.md Show resolved Hide resolved
packages/ra-core/src/form/useAugmentedForm.ts Outdated Show resolved Hide resolved
packages/ra-core/src/form/useRecordFromLocation.ts Outdated Show resolved Hide resolved
packages/ra-core/src/form/Form.stories.tsx Show resolved Hide resolved
@slax57 slax57 added this to the 5.5.0 milestone Dec 18, 2024
@slax57 slax57 merged commit 516d3ea into next Dec 18, 2024
15 checks passed
@slax57 slax57 deleted the allow-record-override-from-location-everywhere branch December 18, 2024 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants