[Required] validation

I'm using Blazor 19.3 server side and this is a piece of code from your examples where I added an error message to the [required] dataannotations.

The problem is that the error message is never showed when I try to confirm an empty textbox

When the "required" is triggered in the InPlaceEditor ?

Supposing I have in the page a lot of InPlaceEditor components, how can I validate all of them clicking on a  button ?


Thanks



<table class="table-section">

    <tr>

        <td class="sample-td"> Enter your name: </td>

        <td class="sample-td">

            <SfInPlaceEditor @bind-Value="exampleModel.Name" Type="Syncfusion.Blazor.InPlaceEditor.InputType.Text" TValue="string">

                <EditorComponent>

                    <EditForm Model="@exampleModel">

                        <DataAnnotationsValidator />

                        <SfTextBox @bind-Value="exampleModel.Name"></SfTextBox>

                        <ValidationMessage For=@(() => exampleModel.Name) />

                    </EditForm>

                </EditorComponent>

            </SfInPlaceEditor>

        </td>

    </tr>

</table>


@code {

    private string primaryKey { get; set; } = "editor1";

    private ExampleModel exampleModel = new ExampleModel();


    public class ExampleModel

    {

        [Required(ErrorMessage = "Insert a value")]

        [StringLength(10, ErrorMessage = "Name is too long.")]

        public string Name { get; set; }

    }

}


6 Replies

RK Revanth Krishnan Syncfusion Team December 17, 2021 12:08 PM UTC

Hi Walter, 
 
 
Good day to you. 
 
 
We have validated your query and we have considered “In-place editor “required” validation not working when initial value is set empty” as a bug from our end and logged the report for the same and the fix will be included with our weekly patch release, which is scheduled on December 28th, 2021. 
 
You can now track the current status of the report, review the proposed resolution timeline, and contact us for any further inquiries through this link: 
 
We appreciate your patience until then. 
 
Regards, 
Revanth 



IS Indrajith Srinivasan Syncfusion Team December 29, 2021 11:19 AM UTC

Sorry for the inconvenience caused,


We are unable to include the fix, for the reported issue with our patch release on 28th December due to its complexity. We will include the fix with our patch release on January 11th 2022.



VJ Vinitha Jeyakumar Syncfusion Team January 12, 2022 01:41 PM UTC

We couldn't include the fix for the issue due to its complexity. We will include the fix with our upcoming patch release on  25th January 2022.



BS Buvana Sathasivam Syncfusion Team January 27, 2022 02:57 PM UTC

Hi Walter, 

Thank you for your patience. 

We have solved your reported problem at the sample level. We have validated the Inplace Editor initial value using the EndEdit event. This event is triggered when a value is submitted to the Blazor Inplace Editor component. Can you please find the below code and sample for your reference? 

<SfInPlaceEditor @bind-Value="exampleModel.Name" Type="Syncfusion.Blazor.InPlaceEditor.InputType.Text" TValue="string"> 
                <EditorComponent> 
                    <EditForm Model="@exampleModel" Context="editContext"> 
                        <DataAnnotationsValidator /> 
                        <SfTextBox @bind-Value="exampleModel.Name"></SfTextBox> 
                        <ValidationMessage For=@(() => exampleModel.Name) /> 
                        <InPlaceEditorEvents TValue="string" EndEdit="@((e)=>EndEditEvent(e, editContext))"></InPlaceEditorEvents> 
                    </EditForm> 
                </EditorComponent> 
            </SfInPlaceEditor> 
 
@code { 
    private string primaryKey { get; set; } = "editor1"; 
    private ExampleModel exampleModel = new ExampleModel(); 
 
    public class ExampleModel 
    { 
        [Required(ErrorMessage = "Insert a value")] 
        [StringLength(10, ErrorMessage = "Name is too long.")] 
        public string Name { get; set; } 
 
        public DateTime DateValue { get; set; } 
    } 
 
    public async Task EndEditEvent(EndEditEventArgs args, EditContext context) 
    { 
        if (args.Action == "Submit")  
        { 
            context.Validate();   
            await Task.Delay(500); 
        } 
    } 
} 




Please let us know if you have any concerns. 

Regards, 
Buvana S 



WM Walter Martin January 31, 2022 11:37 PM UTC

This works perfectly

Thanks a lot




BS Buvana Sathasivam Syncfusion Team February 1, 2022 06:00 AM UTC

Hi Walter, 

We are happy to hear your problem has been solved.  Please let us know if you have any further queries.   

Regards, 
Buvana S 


Loader.
Up arrow icon