From 737dba1af22ee1cd0cc6748231f16e4ce9f53b20 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 7 May 2026 15:32:57 +0800 Subject: [PATCH] Refactor MudBlazor dialog forms to use MudStack for improved layout and spacing --- .../framework/ui/blazor/forms-validation.md | 34 ++-- docs/en/tutorials/book-store/part-03.md | 154 ++++++++++-------- docs/en/tutorials/book-store/part-09.md | 44 ++--- 3 files changed, 124 insertions(+), 108 deletions(-) diff --git a/docs/en/framework/ui/blazor/forms-validation.md b/docs/en/framework/ui/blazor/forms-validation.md index d8acb51776..c7f799c484 100644 --- a/docs/en/framework/ui/blazor/forms-validation.md +++ b/docs/en/framework/ui/blazor/forms-validation.md @@ -71,22 +71,24 @@ The most common pattern is wrapping inputs in a `` and binding the form @using System.ComponentModel.DataAnnotations - - - - - - Submit - + + + + + + + Submit + + @code { diff --git a/docs/en/tutorials/book-store/part-03.md b/docs/en/tutorials/book-store/part-03.md index 942fd5cb0e..259475b27d 100644 --- a/docs/en/tutorials/book-store/part-03.md +++ b/docs/en/tutorials/book-store/part-03.md @@ -1217,29 +1217,31 @@ This code requires a service; Inject the `AbpBlazorMessageLocalizerHelper` at Open the `Books.razor` and add the following code to the end of the page: ````razor - + @L["NewBook"] - - - @foreach (BookType bookTypeValue in Enum.GetValues(typeof(BookType))) - { - @L[$"Enum:BookType.{(int)bookTypeValue}"] - } - - - + + + + @foreach (BookType bookTypeValue in Enum.GetValues(typeof(BookType))) + { + @L[$"Enum:BookType.{(int)bookTypeValue}"] + } + + + + @@ -1253,6 +1255,8 @@ Open the `Books.razor` and add the following code to the end of the page: * The form uses `[Required]`/DataAnnotations for validation; messages are localized via the same `AbpResource` localization system. * The `_createDialog` field, `CloseCreateDialogAsync`, `CreateFormRef` and `CreateEntityAsync` are all defined in `AbpMudCrudPageBase`. Check the [MudBlazor documentation](https://mudblazor.com/components/dialog) if you want to understand the `MudDialog` and other components. +* `MudDialog.Options` widens the dialog (`MaxWidth.Medium` + `FullWidth`) so the form fields are not cramped. +* `MudStack` with `Spacing="3"` keeps the inputs visually separated; without it MudBlazor inputs render flush against each other. * `MudDatePicker.@bind-Date` requires a nullable `DateTime?`. If your DTO uses non-nullable `DateTime`, change it to `DateTime?` (`public DateTime? PublishDate { get; set; }`) when using the MudBlazor variant. {{end}} @@ -1379,29 +1383,31 @@ We can now define a modal to edit the book. Add the following code to the end of {{if BlazorUI == "MudBlazor"}} ````razor - + @EditingEntity.Name - - - @foreach (BookType bookTypeValue in Enum.GetValues(typeof(BookType))) - { - @L[$"Enum:BookType.{(int)bookTypeValue}"] - } - - - + + + + @foreach (BookType bookTypeValue in Enum.GetValues(typeof(BookType))) + { + @L[$"Enum:BookType.{(int)bookTypeValue}"] + } + + + + @@ -1744,29 +1750,31 @@ Here's the complete code to create the book management CRUD page, that has been - + @L["NewBook"] - - - @foreach (BookType bookTypeValue in Enum.GetValues(typeof(BookType))) - { - @L[$"Enum:BookType.{(int)bookTypeValue}"] - } - - - + + + + @foreach (BookType bookTypeValue in Enum.GetValues(typeof(BookType))) + { + @L[$"Enum:BookType.{(int)bookTypeValue}"] + } + + + + @@ -1777,29 +1785,31 @@ Here's the complete code to create the book management CRUD page, that has been - + @EditingEntity.Name - - - @foreach (BookType bookTypeValue in Enum.GetValues(typeof(BookType))) - { - @L[$"Enum:BookType.{(int)bookTypeValue}"] - } - - - + + + + @foreach (BookType bookTypeValue in Enum.GetValues(typeof(BookType))) + { + @L[$"Enum:BookType.{(int)bookTypeValue}"] + } + + + + diff --git a/docs/en/tutorials/book-store/part-09.md b/docs/en/tutorials/book-store/part-09.md index a26ebad018..22c144dd14 100644 --- a/docs/en/tutorials/book-store/part-09.md +++ b/docs/en/tutorials/book-store/part-09.md @@ -1083,21 +1083,23 @@ Create a new Razor Component Page, `/Pages/Authors.razor`, in the {{ if UI == "B - + @L["NewAuthor"] - - - + + + + + @@ -1108,21 +1110,23 @@ Create a new Razor Component Page, `/Pages/Authors.razor`, in the {{ if UI == "B - + @EditingAuthor.Name - - - + + + + +