Open juandld opened 3 months ago
The code uses the id
attribute to name the form controls:
<input class="input" type="email" id="email" />
<input class="input" type="password" id="password" />
However, forms require the name
attribute to provide the names of the values in the submitted form data:
<input class="input" type="email" name="email" />
<input class="input" type="password" name="password" />
Using id
:
started login
data FormData {}
Using name
:
started login
data FormData { email: 'a@a.a', password: 'a' }
I hope this helps!
When trying to use a form action from a component and not from the +page file in the route, I will get a very strange behavior, it will work only if the form is empty.
I have a component that pops up to log in (Which could be a very common use case for any sort of form really):
and this is the +page.server.ts file I have in the /login route
I wanted to use the actions feature to get better at Svelte but I just ended up wasting a bunch of time when I could have just assigned values and made the API request from the component itself.