allow form actions without page component
See original GitHub issueDescribe the problem
I would like to make form actions available from anywhere in the app, as described in the documentation:
<form method="POST" action="/login">
<!-- content -->
</form>
This does however require me to make a route /login
, /logout
, /register
, … while it would make sense to me to group them in one file exporting several actions such that I can do (as in the example from the docs):
<form method="POST" action="/login?/register">
However, if I just make a file /login/+page.server.js
without a +page.js
I get the following error:
node.component is not a function TypeError: node.component is not a function
Describe the proposed solution
Allow to have a similar construct as Actions
in a pure API endpoint (+server.js).
Alternatives considered
Workaround
This can be solved by adding an actual page and redirecting directly (I have no need for a login page in this case).
Importance
nice to have
Additional Information
No response
Issue Analytics
- State:
- Created a year ago
- Comments:13 (11 by maintainers)
Top Results From Across the Web
form with no action and where enter does not reload page
A form without an action attribute is not a form, according to standards - and will actually cause a page reload in some...
Read more >How to submit a form or a part of a form without a page refresh ...
In this article, we will learn how to submit a form or a part of a form without a page refresh using JQuery,...
Read more >The Form element - HTML: HyperText Markup Language | MDN
The <form> HTML element represents a document section containing interactive controls ... Instead, use the accept attribute on <input type=file> elements.
Read more >Submit a Form Without Page Refresh Using jQuery - Code
A great way to improve the user experience of your website is to validate and submit forms without a page refresh.
Read more >Forms - React
This form has the default HTML form behavior of browsing to a new page when the user submits the form. If you want...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok I think I understand now - so it’s about not having to create
login/+server.js
,logout/+server.js
etc files because you’d like to have these things closer together / not as many files lying around. What I don’t understand it the connection to your code example, you use that together with a form. So you want to use the<form method="POST" action="..">
feature but theaction
should point to a+server.js
file?Cool — will close this in that case