MudBlazor/MudBlazor

MudField error is ignored by MudForm validation

Aperta

#6876 aperta il 17 mag 2023

 (13 commenti) (1 reazione) (0 assegnatari)C# (1631 fork)batch import
enhancementhelp wanted

Metriche repository

Star
 (10.394 stelle)
Metriche merge PR
 (Merge medio 6g 6h) (108 PR mergiate in 30 g)

Descrizione

Bug type

Component

Component name

MudField

What happened?

We're using MudField to wrap our custom input controls in order to get a coherent look and feel, as suggested under Advanced Usage in the docs. MudField conveniently provides the Error and ErrorText parameters but since the component is not based on MudFormComponent and does not register with the cascading MudForm those errors are ignored during form validation.

Out of desperation I even considered implementing IFormComponent myself and registering my component with the cascading MudForm just like MudFormComponent does, but even that failed because IForm.Add() is declared internal and thus inaccessible from user code.

Expected behavior

Surely there ought to be a way to create my own input controls and have them participate in the same validation mechanism as the other, built-in controls? What was the reason to not base MudField on MudFormComponent, since that appears to be the primary usage anyway?

Perhaps this could be considered a feature request but the lack of validation is so non-intuitive that I think it should be treated as a bug. I'm willing to make a PR if the MudBlazor team thinks it's a good idea.

Reproduction link

https://try.mudblazor.com/snippet/QOQxEzlrhZIQxdLN

Reproduction steps

  1. Press the "Validate" button

Relevant log output

No response

Version (bug)

6.2.5

Version (working)

No response

What browsers are you seeing the problem on?

Firefox, Chrome, Microsoft Edge

On what operating system are you experiencing the issue?

Windows, Linux

Pull Request

  • I would like to do a Pull Request

Code of Conduct

  • I agree to follow this project's Code of Conduct

Guida contributor