RadzenRequiredValidator with Custom Components

Hello community!

I wanted to ask if the Required Validator can work with Custom Non-Radzen components? I have a situation where i have developed a two-way binding component which works great on Forms, grids, and also inline editing inside Radzen, but i tried to setup a RequiredValidator and set the name property properly in both spots but the Validator isnt triggered.

Does anyone have any knowledge on this or if this is possible?

TIA!

You can try inheriting from the Radzen.FormComponent<T> class.

@korchev,

I have tried this and it will then allow the component to be verified but the ValueChanged functions stop working and on inline edit, when you update the value, it reverts back to the original version. Do you have an idea why this would happen?

When i do not include @inherits Radzen.FormComponent to the top all functions work except validation. When i do inherit, then only the validation works.

Here is a minimal working implementation:

@inherits FormComponent<string>
<input value="@Value" @onchange="@OnChange" />
@code {
    protected async Task OnChange(ChangeEventArgs args)
    {
       Value = args.Value;

       await ValueChanged.InvokeAsync(Value);

       if (FieldIdentifier.FieldName != null) 
       { 
           EditContext?.NotifyFieldChanged(FieldIdentifier); 
       }
       
       await Change.InvokeAsync(Value);
    }
}
1 Like

This helped me alot! Thanks a bunch!

I just want to ask if it's possible to pass a generic type in "@inherits FormComponent 'T'" instead of a hardcoded type ("@inherits FormComponent 'string'")? Also if you can give an example as to how?