From 2aecf336a4d277edfa1e91f95249f1d5e6d0473f Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 7 May 2026 12:10:58 +0800 Subject: [PATCH] Fix MudBlazor docs to match real AbpMudCrudPageBase usage - forms-validation: drop incorrect manual _form.Validate() inside OnCreatingEntityAsync; the base CreateEntityAsync validates CreateFormRef before calling the override hook - book-store/part-03: note that MudDatePicker.@bind-Date requires DateTime? and link the abp-samples/MudBlazorSample reference --- docs/en/framework/ui/blazor/forms-validation.md | 12 ++++-------- docs/en/tutorials/book-store/part-03.md | 1 + 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/docs/en/framework/ui/blazor/forms-validation.md b/docs/en/framework/ui/blazor/forms-validation.md index 7426ab6cab..f46ce6fb81 100644 --- a/docs/en/framework/ui/blazor/forms-validation.md +++ b/docs/en/framework/ui/blazor/forms-validation.md @@ -124,17 +124,13 @@ ABP's MudBlazor CRUD pages (see `AbpMudCrudPageBase`) use a `` contai * `` / `` for date and time * `` for numbers -The page base validates the entire form before calling the application service: +`AbpMudCrudPageBase.CreateEntityAsync` and `UpdateEntityAsync` validate the form for you (`CreateFormRef.Validate()` / `EditFormRef.Validate()`) and only call the corresponding hook when the form is valid. To inject custom logic before the application service call, override `OnCreatingEntityAsync` / `OnUpdatingEntityAsync` (do **not** re-validate inside the override): ```csharp -protected override async Task OnCreatingEntityAsync() +protected override Task OnCreatingEntityAsync() { - await _form.Validate(); - if (!_isValid) - { - return; - } - // ... call AppService + // mutate NewEntity here if needed + return base.OnCreatingEntityAsync(); } ``` diff --git a/docs/en/tutorials/book-store/part-03.md b/docs/en/tutorials/book-store/part-03.md index 5a4ae72eac..7e43e90758 100644 --- a/docs/en/tutorials/book-store/part-03.md +++ b/docs/en/tutorials/book-store/part-03.md @@ -1253,6 +1253,7 @@ 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. +* `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 — see [abp-samples/MudBlazorSample](https://github.com/abpframework/abp-samples/tree/master/MudBlazorSample) for a complete reference. {{end}}