Class MudForm
- Namespace
- MudBlazor
- Assembly
- MudBlazor.dll
public class MudForm : MudComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IMudStateHasChanged, IDisposable, IForm
- Inheritance
-
MudForm
- Implements
- Inherited Members
- Extension Methods
Constructors
MudForm()
public MudForm()
Fields
_errors
protected HashSet<string> _errors
Field Value
_formControls
protected HashSet<IFormComponent> _formControls
Field Value
Properties
ChildContent
Child content of component.
[Parameter]
[Category("Validated data")]
public RenderFragment ChildContent { get; set; }
Property Value
Classname
protected string Classname { get; }
Property Value
Disabled
[Parameter]
[Category("Behavior")]
public bool Disabled { get; set; }
Property Value
Errors
Validation error messages.
[Parameter]
[Category("Validation result")]
public string[] Errors { get; set; }
Property Value
- string[]
ErrorsChanged
[Parameter]
public EventCallback<string[]> ErrorsChanged { get; set; }
Property Value
FieldChanged
Raised when a contained IFormComponent changes its value
[Parameter]
public EventCallback<FormFieldChangedEventArgs> FieldChanged { get; set; }
Property Value
IsTouched
True if any field of the field was touched. This parameter is readonly.
[Parameter]
[Category("Behavior")]
public bool IsTouched { get; set; }
Property Value
IsTouchedChanged
Raised when IsTouched changes.
[Parameter]
public EventCallback<bool> IsTouchedChanged { get; set; }
Property Value
IsValid
Validation status. True if the form is valid and without errors. This parameter is two-way bindable.
[Parameter]
[Category("Validation result")]
public bool IsValid { get; set; }
Property Value
IsValidChanged
Raised when IsValid changes.
[Parameter]
public EventCallback<bool> IsValidChanged { get; set; }
Property Value
Model
Specifies the top-level model object for the form. Used with Fluent Validation
[Parameter]
[Category("Validated data")]
public object? Model { get; set; }
Property Value
OverrideFieldValidation
If a field already has a validation, override it with Validation.
[Parameter]
[Category("Validation")]
public bool? OverrideFieldValidation { get; set; }
Property Value
- bool?
ReadOnly
[Parameter]
[Category("Behavior")]
public bool ReadOnly { get; set; }
Property Value
Spacing
The gap between items, measured in increments of 4px
.
Maximum is 20
.
Default is no spacing.
[Parameter]
[Category("Behavior")]
public int Spacing { get; set; }
Property Value
SuppressImplicitSubmission
When true, will not cause a page refresh on Enter if any input has focus.
[Parameter]
[Category("Behavior")]
public bool SuppressImplicitSubmission { get; set; }
Property Value
Remarks
https://www.w3.org/TR/2018/SPSD-html5-20180327/forms.html#implicit-submission Usually this is not wanted, as it can cause a page refresh in the middle of editing a form. When the form is in a dialog this will cause the dialog to close. So by default we suppress it.
SuppressRenderingOnValidation
When true, the form will not re-render its child contents on validation updates (i.e. when IsValid changes). This is an optimization which can be necessary especially for larger forms on older devices.
[Parameter]
[Category("Behavior")]
public bool SuppressRenderingOnValidation { get; set; }
Property Value
Validation
A default validation func or a validation attribute to use for form controls that don't have one. Supported types are:
Func<T, bool> ... will output the standard error message "Invalid" if false
Func<T, string> ... outputs the result as error message, no error if null
Func<T, IEnumerable< string >> ... outputs all the returned error messages, no error if empty
Func<object, string, IEnumerable< string >> input Form.Model, Full Path of Member ... outputs all the returned error messages, no error if empty
Func<T, Task< bool >> ... will output the standard error message "Invalid" if false
Func<T, Task< string >> ... outputs the result as error message, no error if null
Func<T, Task<IEnumerable< string >>> ... outputs all the returned error messages, no error if empty
Func<object, string, Task<IEnumerable< string >>> input Form.Model, Full Path of Member ... outputs all the returned error messages, no error if empty
System.ComponentModel.DataAnnotations.ValidationAttribute instances
[Parameter]
[Category("Validation")]
public object Validation { get; set; }
Property Value
ValidationDelay
Validation debounce delay in milliseconds. This can help improve rendering performance of forms with real-time validation of inputs i.e. when textfields have Immediate="true".
[Parameter]
[Category("Behavior")]
public int ValidationDelay { get; set; }
Property Value
Methods
BuildRenderTree(RenderTreeBuilder)
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
__builder
RenderTreeBuilder
Dispose()
public void Dispose()
GetDisabledState()
protected bool GetDisabledState()
Returns
GetReadOnlyState()
protected bool GetReadOnlyState()
Returns
OnAfterRenderAsync(bool)
protected override Task OnAfterRenderAsync(bool firstRender)
Parameters
firstRender
bool
Returns
OnEvaluateForm()
protected Task OnEvaluateForm()
Returns
OnInitialized()
protected override void OnInitialized()
ResetAsync()
Reset all form controls and reset their validation state.
public Task ResetAsync()
Returns
ResetTouched()
Reset the isTouched property
public void ResetTouched()
ResetValidation()
Reset the validation state but keep the values.
public void ResetValidation()
ShouldRender()
protected override bool ShouldRender()
Returns
Validate()
Force a validation of all form controls, even if they haven't been touched by the user yet.
public Task Validate()