SamProf / MatBlazor

Material Design components for Blazor and Razor Components
http://www.matblazor.com
MIT License
2.84k stars 386 forks source link

MatAutocomplete does not play nice with EditForm #278

Closed Raveen87 closed 4 years ago

Raveen87 commented 5 years ago

Placing a MatAutocomplete in an EditForm produces a weird error message for me.

The error message I'm getting is this: InvalidOperationException: MatBlazor.MatTextField requires a value for the 'ValueExpression' parameter. Normally this is provided automatically when using 'bind-Value'.

I'm able to reproduce it with this example:

@page "/"

<EditForm Model="selected">
    <MatAutocomplete Collection="@options" ItemType="string" Label="Pick one" @bind-Value="selected"></MatAutocomplete>
</EditForm>

<p>Selected: @selected</p>

@code
{
    private string selected = String.Empty;

    string[] options = new[]
    {
        "One",
        "Two",
        "Three"
    };
}

Placing the MatAutocomplete outside of the EditForm works. So does using for instance an InputText instead of a MatAutocomplete inside the EditForm like this:

<EditForm Model="selected">
    <InputText placeholder="Type something" @bind-Value="selected" />
</EditForm>

I'm using MatBlazor 1.9.0 and .NET Core 3.0.

nguyenvanbien95 commented 5 years ago

I have the same problem. Have anyone available hot solution for that?

bnemetchek commented 5 years ago

Try this: https://github.com/SamProf/MatBlazor/issues/213#issuecomment-538036774

katiep23 commented 4 years ago

Here is what I used: https://docs.telerik.com/blazor-ui/knowledge-base/value-changed-validation-model

sandrohanea commented 4 years ago

Hi! The issues with the EditForm should be fixed after the merge of https://github.com/SamProf/MatBlazor/pull/548.

enkodellc commented 4 years ago

Merged fix into develop branch.