Skip to content

fix: No show error validation message in Field #4908

@IvanBrightest

Description

@IvanBrightest

🐛 Bug Report

In V4, if a form field is not valid, FluentValidationMessage could be used to display the validation error. Also, the input field itself was wrapped in a red frame. However, in V5, the FluentValidationMessage component was removed and, according to the documentation https://fluentui-blazor-v5.azurewebsites.net/Migration/Field , you need to use the FluentField component with the ValidationFor parameter. However, there is no such parameter, and the validation error text does not appear under the field, and the text field does not turn into a red border.

💻 Repro or Code Sample

@page "/test"
@using System.ComponentModel.DataAnnotations

<EditForm Model="@EditForm" OnValidSubmit="@HandleValidSubmit" FormName="starship_fluent_entry" novalidate>
    <DataAnnotationsValidator />
    <FluentValidationSummary />

    <FluentStack Orientation="Orientation.Vertical">
        <div>
            <FluentField Label="Name"
                         Required="true"
                         ValidationFor="@(() => EditForm.Name)">
                <FluentTextInput @bind-Value="EditForm.Name" Width="100%" />
            </FluentField>
        </div>
        <FluentButton Type="ButtonType.Submit" Appearance="ButtonAppearance.Primary">Submit</FluentButton>
    </FluentStack>

    
</EditForm>

@code {
    [SupplyParameterFromForm]
    private TestEditForm EditForm { get; set; } = new();

    class TestEditForm
    {
        [Required]
        public string? Name { get; set; }
    }
    
    private void HandleValidSubmit()
    {
        Console.WriteLine("HandleValidSubmit called");
    }
}

🤔 Expected Behavior

The field will turn into a red frame and a text with a validation error will appear below it.

😯 Current Behavior

None of the above. The text of the form validation error is displayed only in FluentValidationSummary.

💁 Possible Solution

🔦 Context

🌍 Your Environment

  • OS & Device: Linux
  • Browser Google Chrome
  • .NET and Fluent UI Blazor library Version: .net - 10.0.5, Fluent UI - 5.0.0-rc.3-26138.1

Metadata

Metadata

Assignees

Labels

status:in-progressWork is in progressv5For the next major version

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions