Browse Source

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
pull/25380/head
maliming 2 weeks ago
parent
commit
2aecf336a4
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 12
      docs/en/framework/ui/blazor/forms-validation.md
  2. 1
      docs/en/tutorials/book-store/part-03.md

12
docs/en/framework/ui/blazor/forms-validation.md

@ -124,17 +124,13 @@ ABP's MudBlazor CRUD pages (see `AbpMudCrudPageBase`) use a `<MudDialog>` contai
* `<MudDatePicker>` / `<MudTimePicker>` for date and time
* `<MudNumericField>` 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();
}
```

1
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}}

Loading…
Cancel
Save