Is it possible to create entry fields inside a template form dynamically via a button press.
Example:
Alpha is a class containing List<string> betas
Beta is an element of List<string> betas
This works correctly when not contained inside a Template Form, but when I try to implement it using a Template Form it throws this error.
The reason I'm trying to use a Template Form is because I want to implement validation for each entry field.
Any advice would be greatly appreciated.
Hi @copemed,
Yes, you can use a foreach and a collection to create the fields. Here is another thread that shows something similar: RadzenTemplateForm can't submit
My apologies I didn't fully explain my problem.
I have a used a foreach and a collection Alpha.betas
to create the fields, which works correctly when adding new fields outside of a Template Form; however when I try to contain the form within a Template Form and try to add a new field it throws the error shown above.
Add button: Click ="@AddField"
private void AddField() {
newAlpha.betas.Add("");
}
This exception is thrown by the Blazor framework. It doesn't support array indexing for @bind
expressions. The workaround is to use Value and ValueChanged instead:
<RadzenTextBox Value="@items[index].Value"
ValueChanged="@(value => items[index].Value = value)" />
1 Like
Thank you it works perfectly