Implement fluent validation in a kanban card

I've been trying to implement fluenvalidation in a kanban edit card, but I haven't been able to get it to work

<KanbanDialogSettings>

    <Template Context="TemplateContext">

        @{

            StaffTask Model = (StaffTask)TemplateContext;

         }

        <div class="form-group col-md-12">

            <SfTextBox ID="StaffTaskTitle" @bind-Value="@(Model.StaffTaskTitle)" TValue="string" FloatLabelType="FloatLabelType.Auto"

                Placeholder="Staff task title"></SfTextBox>

            <ValidationMessage For="()=>Model.StaffTaskTitle"></ValidationMessage>

        </div>

        <FluentValidator TValidator="StaffTaskValidator"></FluentValidator>

    </Template>

</KanbanDialogSettings>


the error is :

Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]

      Unhandled exception rendering component: Microsoft.AspNetCore.Components.Forms.ValidationMessage`1[System.String] requires a cascading parameter of type EditContext. For example, you can use Microsoft.AspNetCore.Components.Forms.ValidationMessage`1[System.String] inside an EditForm.

System.InvalidOperationException: Microsoft.AspNetCore.Components.Forms.ValidationMessage`1[System.String] requires a cascading parameter of type EditContext. For example, you can use Microsoft.AspNetCore.Components.Forms.ValidationMessage`1[System.String] inside an EditForm.



1 Reply

VJ Vinitha Jeyakumar Syncfusion Team June 19, 2024 10:23 AM UTC

Hi Libardo,

We suspect that the reported issue may have occurred due to the missing of EditForm within the Dialog Template when using fluent validation. 

So, we suggest you to use the fluent validation inside the EditForm by using the Dialog Template.

Code snippet:
 
<KanbanDialogSettings>
   <Template>
       @{
       TasksModel data = (TasksModel)context;
        <EditForm Model="EmployeeDetails" OnValidSubmit="SubmitValidForm">
           <FluentValidator TValidator="EmployeeValidator" />
           <ValidationSummary />
           <table>
               <tbody>
                  ......
.....
               </tbody>
           </table>
       }

       </EditForm>
       }
   </Template>
</KanbanDialogSettings>


Regards,
Vinitha

Loader.
Up arrow icon