Skip to content

EditForm does not bind values #55591

@pimber

Description

@pimber

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When using the EditForm component, the value from the Input* classes are not bounded correctly to the model.

Expected Behavior

I expect that the values from the Input* classes bounds correctly to the model, so that i can get the information from the frontend to the backend.

Steps To Reproduce

  1. Create a new blazor project using: dotnet new blazor
  2. Add new razor page and set navbar to ref to this page and add this to it:
<EditForm Model="Test" OnValidSubmit="HandleSubmit" FormName="Form1" Enhance>
    <InputText @bind-Value="@Test.Name" />
    <button type="submit" >Submit</button>
</EditForm>

@code {
    private Tester Test = new();

    private void HandleSubmit() {
        Console.WriteLine($"Name: {Test.Name}");
    }
    private class Tester {
        public int Id { get; set; }
        public string Name { get; set; }
    }
}
  1. Input some text into the InputText and submit, and then you should see that it prints out nothing.

(Note: I have tested this on two different machine, on my exsisting project and also tried to create a new project on both machine and i get the same when trying to commit)

Exceptions (if any)

No response

.NET Version

8.0.103

Anything else?

.NET SDK:
Version: 8.0.103
Commit: 6a90b4b4bc
Workload version: 8.0.100-manifests.e99a2be4

Runtime Environment:
OS Name: ubuntu
OS Version: 22.04
OS Platform: Linux
RID: ubuntu.22.04-x64
Base Path: /usr/lib/dotnet/sdk/8.0.103/

.NET workloads installed:
Workload version: 8.0.100-manifests.e99a2be4
There are no installed workloads to display.

Host:
Version: 8.0.3
Architecture: x64
Commit: 9f4b1f5d66

.NET SDKs installed:
8.0.103 [/usr/lib/dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.3 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.3 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions