Skip to content

Form Databinding Not working correctly with Nested object - Static SSR form submission #58988

Open
@htmlsplash

Description

@htmlsplash

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

.net 8, .net 9, Blazor static SSR page

I have a form with 2 fields, both reference the same nested object within the criteria object to access the start/end date fiels.

<InputDate class="form-control" @bind-Value="CriteriaFromUserInput.Period.Start" /> <InputDate class="form-control" @bind-Value="CriteriaFromUserInput.Period.End" />

When both fields are supplied (filled out) the databinding works and both values are bound respectively.
If you fill out only 1 of the fields (start or end date) no binding takes place. The start and end will be null (since they are of type DateTime?).

Here's the project that reproduces that problem:
https://github.com/htmlsplash/BlazorWebAppTest

Run project, select Form Test 1 from the nav menu.
Fill out both fields, and observe date fields are databound correctly. Then, fill out only one of the date fields (make sure the other date field has no date), observe the problem described. Also, you will note that the filled out previously date field is cleared because of broken databinding.
NOTE:
I observed this issue when going through nested object in the criteria object. If you move start/end fields to criteria object and bind to these there, individually, it works perfectly fine.
NOTE:
This problem is only happening when you are using static SSR page, it works fine when using interactive server.

Look at the FormDataBindTest1.razor under pages folder to see code.

Expected Behavior

Filling out one of the 2 date fields should still bind to the correct field when form is submitted.

Steps To Reproduce

See description of the bug.

Exceptions (if any)

No response

.NET Version

.net 8 .net 9

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions