Replies: 1 comment 5 replies
-
Can you provide a code example of how you're doing the progressive enhancement? |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there, new SvelteKit user here, on @sveltejs/kit 1.5.3.
I was under the impression from the Form Actions documentation that the objects you return from actions would be available on the page under
form
given it's been initialised asexport let form: ActionData;
. And indeed it does from my testing when using non-enhanced forms.This would allow you to define behaviour on the page that depends on the action's response. For example, if the action
save
returned{ resource, action: 'save', errors: [] }
, then on the page you could checkform
and show a flash/toast that the save was successful, otherwise show any errors.At first I was using a default form w/o enhancement. Problem was that doing a form submission would change the URL to include the route that was called, for example from
/resource/:id
to/resource/:id?/save
after calling thesave
action. I want to perform an action that has a side effect without changing the URL for the user.Making the form progressive with
use:enhance
fixed the URL (though it's not clear to me why that worked from the docs). Unfortunately it also makesform
undefined, meaning I've lost the action responses. I'm not yet sure if this is a bug, but it may be related to #8513. Am I misunderstanding the patterns and trying to do this incorrectly?Beta Was this translation helpful? Give feedback.
All reactions