diff --git a/docs/concepts/forms.md b/docs/concepts/forms.md new file mode 100644 index 00000000..c972a090 --- /dev/null +++ b/docs/concepts/forms.md @@ -0,0 +1,59 @@ +--- +description: | + Robustly handle user inputs using HTML `
+ > + ); +} +``` + +When the user submits the form, Deno will access a specific `email` value from a +`formData()`, add the email to a list, and redirect the user to a thank you +page. diff --git a/docs/getting-started/form-submissions.md b/docs/getting-started/form-submissions.md index ac1a3b94..c566ee68 100644 --- a/docs/getting-started/form-submissions.md +++ b/docs/getting-started/form-submissions.md @@ -18,10 +18,10 @@ JavaScript to make them more interactive. The way forms work in the browser, is that they perform an HTML navigation action when the user submits the form. In most cases this means that when the -form is submitted, a GET or POST request is sent to the server with the form +form is submitted, a `GET` or `POST` request is sent to the server with the form data, which then responds with a new page to render. -Fresh can handle both GET and POST requests through the +Fresh can handle both `GET` and `POST` requests through the [custom handlers][custom-handlers] feature of routes. The handlers can perform any necessary processing on the form data, and then pass data to the `ctx.render()` call to render a new page. @@ -71,6 +71,9 @@ query set as the `q` query parameter in the URL. The `GET` handler will then filter the names array based on the query, and pass it to the page component for rendering. +[Learn more about using forms in Fresh][concepts-forms]. + [custom-handlers]: /docs/getting-started/custom-handlers +[concepts-forms]: /docs/concepts/forms diff --git a/docs/toc.json b/docs/toc.json index 57c28365..5ec37a83 100644 --- a/docs/toc.json +++ b/docs/toc.json @@ -21,6 +21,7 @@ "pages": [ ["architecture", "Architecture"], ["routes", "Routes"], + ["forms", "Forms"], ["islands", "Interactive islands"], ["static-files", "Static files"], ["middleware", "Route middleware"],