Skip to content

Commit

Permalink
Add Steps component to build-forms.mdx (#8124)
Browse files Browse the repository at this point in the history
Co-authored-by: Houston (Bot) <[email protected]>
Co-authored-by: Sarah Rainsberger <[email protected]>
  • Loading branch information
3 people authored May 2, 2024
1 parent d4b080f commit 76e43a7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/content/docs/en/recipes/build-forms.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ description: Learn how to build HTML forms and handle submissions in your frontm
i18nReady: true
type: recipe
---
import { Steps } from '@astrojs/starlight/components';

In SSR mode, Astro pages can both display and handle forms. In this recipe, you'll use a standard HTML form to submit data to the server. Your frontmatter script will handle the data on the server, sending no JavaScript to the client.


## Prerequisites
- A project with [SSR](/en/guides/server-side-rendering/) (`output: 'server'`) enabled

## Recipe

<Steps>
1. Create or identify a `.astro` page which will contain your form and your handling code. For example, you could add a registration page:

```astro title="src/pages/register.astro"
Expand Down Expand Up @@ -139,7 +140,7 @@ In SSR mode, Astro pages can both display and handle forms. In this recipe, you'
</form>
```

5. Validate the form data on the server. This should include the same validation done on the client to prevent malicious submissions to your endpoint and to support the rare legacy browser that doesn't have form validation.
6. Validate the form data on the server. This should include the same validation done on the client to prevent malicious submissions to your endpoint and to support the rare legacy browser that doesn't have form validation.

It can also include validation that can't be done on the client. For example, this example checks if the email is already in the database.

Expand Down Expand Up @@ -201,5 +202,4 @@ In SSR mode, Astro pages can both display and handle forms. In this recipe, you'
</form>
```


</Steps>

0 comments on commit 76e43a7

Please sign in to comment.