Skip to content

Commit ab0ac64

Browse files
committed
Update example of editform
1 parent 52f875d commit ab0ac64

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

projects/.net8/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ These samples require [.NET 8.0 Preview 7](https://github.com/dotnet/installer#t
7878

7979
* [RazorFormHandlingTwo](RazorFormHandlingTwo)
8080

81-
This example shows how to perform automatic data binding for a form `POST` request using `[SupplyParameterFromForm]`.
82-
81+
This example shows how to perform automatic data binding for a form `POST` request using `<EditForm/>` and `[SupplyParameterFromForm]`.
8382

8483
## Mix and Match
8584

projects/.net8/RazorFormHandlingTwo/Pages/Index.razor

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
@page "/"
2-
@inject FormDataProvider FormData
32

43
<h1>Automatic Model Binding</h1>
54

@@ -9,7 +8,7 @@
98
<br />
109
<div class="row">
1110
<div class="col-md-6">
12-
<EditForm method="POST" Model="PersonInfo" OnValidSubmit="HandleSubmit">
11+
<EditForm method="POST" Model="PersonInfo" FormName="info" OnValidSubmit="HandleSubmit">
1312
<div class="mb-3">
1413
<label class="form-label" for="PersonInfo.Name">Please enter your name</label><br />
1514
<InputText @bind-Value="PersonInfo.Name" class="form-control" />
@@ -53,7 +52,7 @@
5352

5453
@code
5554
{
56-
[SupplyParameterFromForm]
55+
[SupplyParameterFromForm(Handler = "info")] // matches FormName="info"
5756
public Person PersonInfo { get; set; } = new();
5857

5958
string _showMessage = string.Empty;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# Form Handling in Blazor SSR - Automatic binding using [SupplyParameterFromForm]
1+
# Form Handling in Blazor SSR - Automatic binding using EditForm and [SupplyParameterFromForm]
22

3-
This example shows how to perform automatic data binding for a form `POST` request using `[SupplyParameterFromForm]`.
3+
This example shows how to perform automatic data binding for a form `POST` request using `<EditForm/>` and `[SupplyParameterFromForm]`. `EditForm` will generate the antiforgery token so there is no need to include `<AntiforgeryToken/>` component manually.

0 commit comments

Comments
 (0)