FormComponent<T> Class

Base class for all Radzen form input components providing data binding, validation, and change event capabilities. FormComponent integrates with Blazor's EditContext for form validation and provides common functionality for all input controls. This is the base class for components like RadzenTextBox, RadzenCheckBox, RadzenDropDown, RadzenDatePicker, etc. Provides @bind-Value support for two-way binding, integration with Blazor EditContext and validators, Change and ValueChanged callbacks, Disable property to prevent user interaction, Placeholder text for empty inputs, Name property for validation and label association, and TabIndex for keyboard navigation control. Components inheriting from FormComponent automatically work with RadzenTemplateForm and validators.

Inheritance

Object

ComponentBase

RadzenComponent

FormComponent<T>

Implements

IComponent

IHandleEvent

IHandleAfterRender

IRadzenFormComponent

Namespace: Radzen

Assembly: Radzen.Blazor.dll

Syntax

public class FormComponent<T> : RadzenComponent, IComponent, IHandleEvent, IHandleAfterRender, IRadzenFormComponent

Type Parameters

Name Description
TThe type of the component's bound value (string, int, DateTime, etc.).

Constructors

FormComponent<T>Link to this section

Base class for all Radzen form input components providing data binding, validation, and change event capabilities. FormComponent integrates with Blazor's EditContext for form validation and provides common functionality for all input controls. This is the base class for components like RadzenTextBox, RadzenCheckBox, RadzenDropDown, RadzenDatePicker, etc. Provides @bind-Value support for two-way binding, integration with Blazor EditContext and validators, Change and ValueChanged callbacks, Disable property to prevent user interaction, Placeholder text for empty inputs, Name property for validation and label association, and TabIndex for keyboard navigation control. Components inheriting from FormComponent automatically work with RadzenTemplateForm and validators.

Declaration
public FormComponent<T>()

Fields

_valueLink to this section

The value

Declaration
protected T _value

Properties

ChangeLink to this section

Gets or sets the change.

Declaration
public EventCallback<T> Change { get; set; }
Property Value
Type Description
EventCallback<T>Gets or sets the change.

CurrentPlaceholderLink to this section

Gets the current placeholder. Returns empty string if this component is inside a RadzenFormField.

Declaration
protected string CurrentPlaceholder { get; }
Property Value
Type Description
stringGets the current placeholder. Returns empty string if this component is inside a RadzenFormField.

DisabledLink to this section

Gets or sets a value indicating whether this FormComponent<T> is disabled.

Declaration
public bool Disabled { get; set; }
Property Value
Type Description
boolGets or sets a value indicating whether this FormComponent<T> is disabled.

EditContextLink to this section

Gets or sets the edit context.

Declaration
public Forms.EditContext EditContext { get; set; }
Property Value
Type Description
Forms.EditContextGets or sets the edit context.

FieldIdentifierLink to this section

Gets the field identifier.

Declaration
public Forms.FieldIdentifier FieldIdentifier { get; set; }
Property Value
Type Description
Forms.FieldIdentifierGets the field identifier.

FormLink to this section

Gets or sets the form.

Declaration
public IRadzenForm Form { get; set; }
Property Value
Type Description
IRadzenFormGets or sets the form.

FormFieldContextLink to this section

Provides support for RadzenFormField integration.

Declaration
public IFormFieldContext FormFieldContext { get; set; }
Property Value
Type Description
IFormFieldContextProvides support for RadzenFormField integration.

HasValueLink to this section

Gets a value indicating whether this instance has value.

Declaration
public bool HasValue { get; }
Property Value
Type Description
boolGets a value indicating whether this instance has value.

IsBoundLink to this section

Gets a value indicating whether this instance is bound.

Declaration
public bool IsBound { get; }
Property Value
Type Description
boolGets a value indicating whether this instance is bound.

NameLink to this section

Gets or sets the unique name identifier for this form component. Used for validation association (linking with validators and labels) and for identifying the field in form submission. This name should be unique within the form and match the Component property of associated validators/labels.

Declaration
public string Name { get; set; }
Property Value
Type Description
stringGets or sets the unique name identifier for this form component. Used for validation association (linking with validators and labels) and for identifying the field in form submission. This name should be unique within the form and match the Component property of associated validators/labels.

PlaceholderLink to this section

Gets or sets the placeholder.

Declaration
public string Placeholder { get; set; }
Property Value
Type Description
stringGets or sets the placeholder.

TabIndexLink to this section

Gets or sets the tab order index for keyboard navigation. Controls the order in which fields receive focus when the user presses the Tab key. Lower values receive focus first. Use -1 to exclude from tab navigation.

Declaration
public int TabIndex { get; set; }
Property Value
Type Description
intGets or sets the tab order index for keyboard navigation. Controls the order in which fields receive focus when the user presses the Tab key. Lower values receive focus first. Use -1 to exclude from tab navigation.

ValueLink to this section

Gets or sets the value.

Declaration
public T Value { get; set; }
Property Value
Type Description
TGets or sets the value.

ValueChangedLink to this section

Gets or sets the value changed.

Declaration
public EventCallback<T> ValueChanged { get; set; }
Property Value
Type Description
EventCallback<T>Gets or sets the value changed.

ValueExpressionLink to this section

Gets or sets the value expression.

Declaration
public Expressions.Expression<Func<T>> ValueExpression { get; set; }
Property Value
Type Description
Expressions.Expression<Func<T>>Gets or sets the value expression.

Methods

DisposeLink to this section

Disposes this instance.

Declaration
public override void Dispose()

FocusAsyncLink to this section

Declaration
public virtual ValueTask FocusAsync()
Returns
Type Description
ValueTask

GetClassListLink to this section

Gets the class list.

Declaration
protected Rendering.ClassList GetClassList(string className)
Parameters
Type Name Description
string className Name of the class.
Returns
Type Description
Rendering.ClassListClassList.

GetValueLink to this section

Gets the value.

Declaration
public object GetValue()
Returns
Type Description
objectSystem.Object.

NotifyFieldChangedLink to this section

Notifies the EditContext that the field has changed while validators observe the specified value. The stored value is restored afterwards so that two-way binding parameter re-flow keeps working as expected.

Declaration
protected void NotifyFieldChanged(T value)
Parameters
Type Name Description
T value The value validators should observe during the notification.

OnContextMenuLink to this section

Handles the ContextMenu event.

Declaration
public override Task OnContextMenu(MouseEventArgs args)
Parameters
Type Name Description
MouseEventArgs args The MouseEventArgs instance containing the event data.
Returns
Type Description
TaskTask.

SetParametersAsyncLink to this section

Sets the parameters asynchronous.

Declaration
public override Task SetParametersAsync(ParameterView parameters)
Parameters
Type Name Description
ParameterView parameters The parameters.
Returns
Type Description
TaskTask.
An error has occurred. This app may no longer respond until reloaded. Reload 🗙