10

I'm looking for a way to post a MudForm upon pressing Enter from any control inside the form, without checking each keyboardevent argument and filtering for Enter, and without binding the listener to each form control in every MudForm.

The goal is to post any MudForm across my project by pressing Enter as a default behavior.

Barnebyte
  • 161
  • 5

2 Answers2

0

You will need to use EditForm for this: https://mudblazor.com/components/form#editform-support

Halden Collier
  • 845
  • 7
  • 18
0

I am not sure what you want to achieve, but I give it a go with my thoughts.

MudTextField updates the bound value on Enter or when it loses focus, meaning you can initiate the posting process from the setter.

<MudTextField @bind-Value="Name" Label="Enter your name" />
public User user;

public string Name 
{ 
    get { return user.name; }
    set { user.name = value; DoPostInfo(); }
}

The downside is that you can't make DoPostInfo async without putting some extra work into it.

Raymond A.
  • 496
  • 7
  • 18