Skip to content

Commit 2d2c3ec

Browse files
authored
EditForm examples update (#30997)
1 parent 63b3a67 commit 2d2c3ec

File tree

4 files changed

+16
-34
lines changed

4 files changed

+16
-34
lines changed

aspnetcore/blazor/forms/binding.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ In the following example, the `HelloFormFromLibrary` component has a form named
166166
`HelloFormFromLibrary.razor`:
167167

168168
```razor
169-
<EditForm method="post" Model="@this" OnSubmit="@Submit" FormName="Hello">
169+
<EditForm Model="@this" OnSubmit="@Submit" FormName="Hello">
170170
<InputText @bind-Value="Name" />
171171
<button type="submit">Submit</button>
172172
</EditForm>
@@ -201,7 +201,7 @@ The following `NamedFormsWithScope` component uses the library's `HelloFormFromL
201201
202202
<div>Hello form using the same form name</div>
203203
204-
<EditForm method="post" Model="@this" OnSubmit="@Submit" FormName="Hello">
204+
<EditForm Model="@this" OnSubmit="@Submit" FormName="Hello">
205205
<InputText @bind-Value="Name" />
206206
<button type="submit">Submit</button>
207207
</EditForm>
@@ -239,14 +239,12 @@ The following example independently binds two forms to their models by form name
239239
@rendermode RenderMode.InteractiveServer
240240
@inject ILogger<Starship6> Logger
241241
242-
<EditForm method="post" Model="@Model1" OnSubmit="@Submit1"
243-
FormName="Holodeck1">
242+
<EditForm Model="@Model1" OnSubmit="@Submit1" FormName="Holodeck1">
244243
<InputText @bind-Value="Model1!.Id" />
245244
<button type="submit">Submit</button>
246245
</EditForm>
247246
248-
<EditForm method="post" Model="@Model2" OnSubmit="@Submit2"
249-
FormName="Holodeck2">
247+
<EditForm Model="@Model2" OnSubmit="@Submit2" FormName="Holodeck2">
250248
<InputText @bind-Value="Model2!.Id" />
251249
<button type="submit">Submit</button>
252250
</EditForm>
@@ -342,8 +340,7 @@ The main form is bound to the `Ship` class. The `StarshipSubform` component is u
342340
@rendermode RenderMode.InteractiveServer
343341
@inject ILogger<Starship7> Logger
344342
345-
<EditForm method="post" Model="@Model" OnSubmit="@Submit"
346-
FormName="Starship7">
343+
<EditForm Model="@Model" OnSubmit="@Submit" FormName="Starship7">
347344
<div>
348345
<label>
349346
Id:

aspnetcore/blazor/forms/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ A form is defined using the Blazor framework's <xref:Microsoft.AspNetCore.Compon
111111
@rendermode RenderMode.InteractiveServer
112112
@inject ILogger<Starship1> Logger
113113
114-
<EditForm method="post" Model="@Model" OnSubmit="@Submit" FormName="Starship1">
114+
<EditForm Model="@Model" OnSubmit="@Submit" FormName="Starship1">
115115
<InputText @bind-Value="Model!.Id" />
116116
<button type="submit">Submit</button>
117117
</EditForm>
@@ -208,7 +208,7 @@ In the next example, the preceding component is modified to create the form in t
208208
@rendermode RenderMode.InteractiveServer
209209
@inject ILogger<Starship2> Logger
210210
211-
<EditForm method="post" Model="@Model" OnValidSubmit="@Submit" FormName="Starship2">
211+
<EditForm Model="@Model" OnValidSubmit="@Submit" FormName="Starship2">
212212
<DataAnnotationsValidator />
213213
<ValidationSummary />
214214
<InputText @bind-Value="Model!.Id" />

aspnetcore/blazor/forms/input-components.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ The following form accepts and validates user input using:
132132
133133
<h2>New Ship Entry Form</h2>
134134
135-
<EditForm method="post" Model="@Model" OnValidSubmit="@Submit" FormName="Starship3">
135+
<EditForm Model="@Model" OnValidSubmit="@Submit" FormName="Starship3">
136136
<DataAnnotationsValidator />
137137
<ValidationSummary />
138138
<div>
@@ -314,8 +314,7 @@ In the following example:
314314
@rendermode RenderMode.InteractiveServer
315315
@inject ILogger<Starship4> Logger
316316
317-
<EditForm method="post" EditContext="@editContext" OnSubmit="@Submit"
318-
FormName="Starship4">
317+
<EditForm EditContext="@editContext" OnSubmit="@Submit" FormName="Starship4">
319318
<DataAnnotationsValidator />
320319
<div>
321320
<label>
@@ -458,8 +457,7 @@ In the following example, the user must select at least two starship classificat
458457
459458
<h1>Bind Multiple <code>InputSelect</code> Example</h1>
460459
461-
<EditForm method="post" EditContext="@editContext" OnValidSubmit="@Submit"
462-
FormName="Starship5">
460+
<EditForm EditContext="@editContext" OnValidSubmit="@Submit" FormName="Starship5">
463461
<DataAnnotationsValidator />
464462
<ValidationSummary />
465463
<div>

aspnetcore/blazor/forms/validation.md

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ In the following component, the `HandleValidationRequested` handler method clear
3030
3131
<h2>Holodeck Configuration</h2>
3232
33-
<EditForm method="post" EditContext="editContext" OnValidSubmit="@Submit"
34-
FormName="Starship8">
33+
<EditForm EditContext="editContext" OnValidSubmit="@Submit" FormName="Starship8">
3534
<div>
3635
<label>
3736
<InputCheckbox @bind-Value="Model!.Subsystem1" />
@@ -327,7 +326,7 @@ When validation messages are set in the component, they're added to the validato
327326
328327
<h2>New Ship Entry Form</h2>
329328
330-
<EditForm method="post" Model="@Model" OnValidSubmit="@Submit" FormName="Starship9">
329+
<EditForm Model="@Model" OnValidSubmit="@Submit" FormName="Starship9">
331330
<CustomValidation @ref="customValidation" />
332331
<ValidationSummary />
333332
<div>
@@ -739,7 +738,7 @@ In the following component, update the namespace of the **`Shared`** project (`@
739738
740739
<h2>New Ship Entry Form</h2>
741740
742-
<EditForm method="post" Model="@Model" OnValidSubmit="@Submit" FormName="Starship10">
741+
<EditForm Model="@Model" OnValidSubmit="@Submit" FormName="Starship10">
743742
<DataAnnotationsValidator />
744743
<CustomValidation @ref="customValidation" />
745744
<ValidationSummary />
@@ -1042,7 +1041,7 @@ The `CustomInputText` component can be used anywhere <xref:Microsoft.AspNetCore.
10421041
@rendermode RenderMode.InteractiveServer
10431042
@inject ILogger<Starship11> Logger
10441043
1045-
<EditForm method="post" Model="@Model" OnValidSubmit="@Submit" FormName="Starship11">
1044+
<EditForm Model="@Model" OnValidSubmit="@Submit" FormName="Starship11">
10461045
<DataAnnotationsValidator />
10471046
<ValidationSummary />
10481047
<CustomInputText @bind-Value="Model!.Id" />
@@ -1254,25 +1253,20 @@ The following component validates user input by applying the `SaladChefValidator
12541253
@inject SaladChef SaladChef
12551254
12561255
<EditForm Model="@this" autocomplete="off" FormName="Starship12">
1257-
12581256
<DataAnnotationsValidator />
1259-
12601257
<p>
12611258
<label>
12621259
Salad topper (@saladToppers):
12631260
<input @bind="SaladIngredient" />
12641261
</label>
12651262
</p>
1266-
12671263
<button type="submit">Submit</button>
1268-
12691264
<ul>
12701265
@foreach (var message in context.GetValidationMessages())
12711266
{
12721267
<li class="validation-message">@message</li>
12731268
}
12741269
</ul>
1275-
12761270
</EditForm>
12771271
12781272
@code {
@@ -1295,25 +1289,20 @@ The following component validates user input by applying the `SaladChefValidator
12951289
@inject SaladChef SaladChef
12961290
12971291
<EditForm Model="@this" autocomplete="off">
1298-
12991292
<DataAnnotationsValidator />
1300-
13011293
<p>
13021294
<label>
13031295
Salad topper (@saladToppers):
13041296
<input @bind="SaladIngredient" />
13051297
</label>
13061298
</p>
1307-
13081299
<button type="submit">Submit</button>
1309-
13101300
<ul>
13111301
@foreach (var message in context.GetValidationMessages())
13121302
{
13131303
<li class="validation-message">@message</li>
13141304
}
13151305
</ul>
1316-
13171306
</EditForm>
13181307
13191308
@code {
@@ -1412,8 +1401,7 @@ Set the `CustomFieldClassProvider` class as the Field CSS Class Provider on the
14121401
@rendermode RenderMode.InteractiveServer
14131402
@inject ILogger<Starship13> Logger
14141403
1415-
<EditForm method="post" EditContext="@editContext" OnValidSubmit="@Submit"
1416-
FormName="Starship13">
1404+
<EditForm EditContext="@editContext" OnValidSubmit="@Submit" FormName="Starship13">
14171405
<DataAnnotationsValidator />
14181406
<ValidationSummary />
14191407
<InputText @bind-Value="Model!.Id" />
@@ -1782,8 +1770,7 @@ To enable and disable the submit button based on form validation, the following
17821770
@implements IDisposable
17831771
@inject ILogger<Starship14> Logger
17841772
1785-
<EditForm method="post" EditContext="@editContext" OnValidSubmit="@Submit"
1786-
FormName="Starship14">
1773+
<EditForm EditContext="@editContext" OnValidSubmit="@Submit" FormName="Starship14">
17871774
<DataAnnotationsValidator />
17881775
<ValidationSummary />
17891776
<div>

0 commit comments

Comments
 (0)