havit / Havit.Blazor

Free Bootstrap 5 components for ASP.NET Blazor + optional enterprise-level stack for Blazor development (gRPC code-first, layered architecture, localization, auth, ...)
https://havit.blazor.eu
MIT License
496 stars 67 forks source link

[HxInputText] error with array #874

Closed romaluca closed 2 months ago

romaluca commented 2 months ago

I have an array of strings, Place.Sites, that I'm trying to manage using the HxInputText component. My current code looks like this:

@for (int x=0; x < Place.Sites.Count();x++)
        {
            int i = x;
        <p>
            <HxInputText Label="Sites" @bind-Value="Place.Sites[i]" />
        </p>
        }

However, this code raises the following error:

InvalidOperationException: Sequence contains no elements System.Linq.ThrowHelper.ThrowNoElementsException() System.Linq.Enumerable.Single(IEnumerable source) Havit.Blazor.Components.Web.Bootstrap.HxInputBase.GetValueAttribute() Havit.Blazor.Components.Web.Bootstrap.HxInputTextBase.BuildRenderInput(RenderTreeBuilder builder) Havit.Blazor.Components.Web.Bootstrap.HxInputBase.Havit.Blazor.Components.Web.Bootstrap.Internal.IFormValueComponent.RenderValue(RenderTreeBuilder builder)

if I switch to the standard InputText component, the code works as expected:


@for (int x=0; x < Place.Sites.Count();x++)
        {
            int i = x;
        <p>
            <InputText Label="Sites" @bind-Value="Place.Sites[i]" />
        </p>
        }

How can i use HxInputText instead of InputText? Thanks

hakenr commented 2 months ago

Thanks for reporting this. I was able to reproduce the issue and it is fixed now. Will be part of next release.