From 877c4d5579557c5167bb0b97e885ed452f6b1c1b Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Thu, 17 Aug 2023 10:48:38 -0400 Subject: [PATCH] Blazor forms and antiforgery 8.0 updates (2) --- .../blazor/forms-and-input-components.md | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/aspnetcore/blazor/forms-and-input-components.md b/aspnetcore/blazor/forms-and-input-components.md index c6ed4169a932..a6862f1d2cd4 100644 --- a/aspnetcore/blazor/forms-and-input-components.md +++ b/aspnetcore/blazor/forms-and-input-components.md @@ -145,7 +145,7 @@ A form is defined using the Blazor framework's Logger - + @@ -242,7 +242,7 @@ In the next example, the preceding component is modified to create the form in t @attribute [RenderModeServer] @inject ILogger Logger - + @@ -452,7 +452,7 @@ builder.Services.AddRazorComponents(options => ### Form names -Form names must be unique to bind model data. When a form name is provided, use the `FormName` parameter. The following form is named `RomulanAle`: +Use the `FormName` parameter to assign a form name. Form names must be unique to bind model data. The following form is named `RomulanAle`: ```razor @@ -460,24 +460,17 @@ Form names must be unique to bind model data. When a form name is provided, use ``` -Supplying a form name isn't required if only one form is present in a component. Form names also aren't required when using multiple child components with forms, as long as each child only has a single form. If a child component has multiple forms, the forms are named in the child component. +Supplying a form name: -`MultipleForms.razor`: + -```razor -@page "/multiple-forms" - -

Combine Forms

- -
- Form names NOT required for Starship1 - and Starship2 form components. -
+* Is required on all forms that are submitted via server-side rendering (SSR). +* Not required for interactive rendering, which includes forms in Blazor WebAssembly apps and components marked with an interactive render mode. - +The form name is only checked when the form is posted to an endpoint as a traditional HTTP POST request (an SSR form post). The framework doesn't throw an exception at the point of rendering a form, but only at the point that an HTTP POST arrives and doesn't specify a form name. - -``` +> [!WARNING] +> We recommend supplying a unique form name for every form to prevent runtime form posting errors. Define a scope for form names using the `FormMappingScope` component, which is useful for preventing form name collisions when a library supplies a form to a component and you have no way to control the form name used by the library's developer. By default, there's an empty-named scope above the app's root component, which suffices when there are no form name collisions. @@ -658,7 +651,7 @@ The main form is bound to the `Ship` class. The `StarshipSubform` component is u @attribute [RenderModeServer] @inject ILogger Logger - +