-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed as not planned
Closed as not planned
Copy link
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationlow hanging fruit
Milestone
Description
Discussed in #10842
Native form submission always navigates to the route specified in the form action attribute. However, use:enhance doesn’t reflect this since it only navigates to another page if you explicitly throw a redirect in your action in +page.server.js.
We should document this in https://kit.svelte.dev/docs/form-actions#progressive-enhancement-use-enhance
Another thing we could document is how to emulate the navigation to the action route after a successful response with a goto call https://kit.svelte.dev/docs/modules#$app-navigation-goto
<form
action="/somewhere/else"
method="post"
use:enhance={({ formElement, formData, action, cancel }) => {
return async ({ result }) => {
// emulate native browser form redirect
if (result.type === "success") {
await goto(action);
}
await applyAction(result);
};
}}
>
<button type="submit">
Submit
</button>
</form>Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationlow hanging fruit