Skip to content

Please make EditForm always return its EditContext #12238

@PeterHimschoot

Description

@PeterHimschoot

Describe the bug

When the EditForm component binds through the Model property, accessing the EditContext property returns null. Why not return the _fixedEditContext?

To Reproduce

I have a component with this EditForm:

<EditForm @ref="editForm"
          OnValidSubmit="@Submit"
          Model="@Customer">

In its @code I have this:

private EditForm editForm;

private bool isInvalid = false;

protected  override void OnInit()
{
    if( editForm?.EditContext == null)
  {
    Console.WriteLine("??? EditContext is null???");
  } else
  {
    isInvalid = editForm.EditContext.Validate();
  }

Expected behavior

I would expect that EditContext has a value, even though not set myself.

Additional context

This is on Blazor Preview 6

Metadata

Metadata

Assignees

No one assigned

    Labels

    DoneThis issue has been fixedarea-blazorIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing onehelp wantedUp for grabs. We would accept a PR to help resolve this issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions