Class
TelerikForm

A comprehensive form component that provides automatic field generation, validation integration, and flexible layout options for data entry scenarios. Supports both automatic form creation from model properties and manual field definition with extensive customization capabilities. Use this component for user registration, data editing, settings pages, and any scenario requiring structured data input with validation. Features include automatic editor selection, grid-based layouts, validation message display, and responsive form orientation.

Definition

Namespace:Telerik.Blazor.Components

Assembly:Telerik.Blazor.dll

Syntax:

cs-api-definition
public class TelerikForm : BaseComponent, IComponent, IHandleEvent, IHandleAfterRender, IDisposable, IFormItemsContainer

Inheritance: objectComponentBaseBaseComponentTelerikForm

Implements: IComponentIDisposableIFormItemsContainerIHandleAfterRenderIHandleEvent

Inherited Members BaseComponent.ShouldRender()BaseComponent.OnInitializedAsync()BaseComponent.OnAfterRenderAsync(bool)BaseComponent.Dispose()BaseComponent.InitLocalizer()BaseComponent.ThrowIfParameterIsNull(object, string)BaseComponent.HaveOptionsChanged(IDictionary<string, object>, IDictionary<string, object>)BaseComponent.GetClassString(params string[])BaseComponent.InvokeAsync<T>(string, params object[])BaseComponent.InvokeAsync<T>(string, CancellationToken, params object[])BaseComponent.InvokeVoidAsync(string, params object[])BaseComponent.InvokeComponentMethodAsync<T>(string, params object[])BaseComponent.InvokeComponentMethodAsync<T>(string, CancellationToken, params object[])BaseComponent.InvokeVoidComponentMethodAsync(string, params object[])BaseComponent.InvokeComponentVoidMethodAsync(string, object)BaseComponent.InvokeDisposeAsync()BaseComponent.StateHasChanged()BaseComponent.RootComponentBaseComponent.ClassComponentBase.OnInitialized()ComponentBase.OnParametersSetAsync()ComponentBase.OnAfterRender(bool)ComponentBase.InvokeAsync(Action)ComponentBase.InvokeAsync(Func<Task>)ComponentBase.DispatchExceptionAsync(Exception)

Constructors

TelerikForm()

Declaration

cs-api-definition
public TelerikForm()

Properties

AutoComplete

Controls browser autocomplete behavior for the entire form using standard HTML autocomplete values. Use "on" to enable browser autocomplete for faster form filling, "off" to disable it for sensitive data. Accepts specific autocomplete values like "new-password" for new password fields or "current-password" for login forms. This setting applies to all form fields unless individual fields override it with their own autocomplete attributes. Helpful for improving user experience in frequently used forms or securing sensitive data entry.

Declaration

cs-api-definition
[Parameter]
public string AutoComplete { get; set; }

Property Value

string

ButtonsLayout

Controls the horizontal alignment of form action buttons within their container area. Start aligns buttons to the left side of the form. Center centers buttons horizontally for balanced appearance. End aligns buttons to the right side, following common form conventions. Stretch makes buttons expand to fill available width equally. When not specified, defaults automatically based on Orientation - horizontal forms use End, vertical forms use Start.

Declaration

cs-api-definition
[Parameter]
public FormButtonsLayout? ButtonsLayout { get; set; }

Property Value

FormButtonsLayout?

ColumnSpacing

Controls the horizontal spacing between columns in multi-column form grid layouts. Accepts any valid CSS length value such as "16px", "1rem", "2em", or "1%". Only takes effect when Columns is set to a value greater than 1 to enable grid layout. Use larger values like "48px" for more spacious layouts, or smaller values like "16px" for compact designs. Default value is "32px" providing balanced spacing suitable for most form designs.

Declaration

cs-api-definition
[Parameter]
public string ColumnSpacing { get; set; }

Property Value

string

Columns

Specifies the number of columns for automatic grid-based form layout when using auto-generated fields. When set to a value greater than 0, form fields automatically arrange themselves in a CSS Grid with the specified number of columns. Use values like 2 for two-column layouts, 3 for three-column layouts, etc. Set to 0 (default) for single-column stacked layout. Works together with ColumnSpacing and RowSpacing to control spacing between grid items. Best suited for forms with many fields that can benefit from horizontal organization.

Declaration

cs-api-definition
[Parameter]
public int Columns { get; set; }

Property Value

int

EditContext

Specifies the form's edit context for advanced validation scenarios and custom validation logic. Use this when you need full control over form validation state, field tracking, and validation messages. Cannot be used together with Model - provide either EditContext or Model, not both. Typically used in complex forms where you manage validation programmatically or integrate with custom validation frameworks.

Declaration

cs-api-definition
[Parameter]
public EditContext EditContext { get; set; }

Property Value

EditContext

FormButtons

Defines custom action buttons that appear at the bottom of the form. When not specified, the form automatically renders a default Submit button. Use this to add custom buttons like Save, Cancel, Reset, or to completely replace the default submit behavior. Buttons placed here have access to the form's EditContext and can trigger custom form submission logic. Common scenarios include multi-step forms, forms with preview functionality, or custom save operations.

Declaration

cs-api-definition
[Parameter]
public RenderFragment FormButtons { get; set; }

Property Value

RenderFragment

FormItems

Defines the form input fields and their organization within the form layout. Use this to manually specify which fields to display, their labels, validation rules, and custom editors. When not provided, the form automatically generates fields from the Model properties using reflection. Allows full control over field ordering, grouping, and custom input components beyond standard auto-generated fields. Children: FormItem and FormGroup tags.

Declaration

cs-api-definition
[Parameter]
public RenderFragment FormItems { get; set; }

Property Value

RenderFragment

FormItemsTemplate

Defines a custom template for rendering form items with full control over the layout and structure. Use this for advanced scenarios where you need to completely customize how form fields are arranged and displayed. The template receives a FormItemsTemplateContext containing all form items in their original structure and order from FormItems. Items can be either IFormItem for individual fields or IFormGroup for grouped fields, allowing complex nested layouts. Requires manual rendering using TelerikFormItemRenderer for fields and TelerikFormGroupRenderer for groups. Children: TelerikFormItemRenderer and TelerikFormGroupRenderer tags.

Declaration

cs-api-definition
[Parameter]
public RenderFragment<FormItemsTemplateContext> FormItemsTemplate { get; set; }

Property Value

RenderFragment<FormItemsTemplateContext>

FormValidation

Defines the form validation components area that appears before form fields and buttons. Use this to add validation components that apply to the entire form, such as validation summaries or custom validation displays. Renders at the top of the form, above FormItems and FormButtons. Common usage includes DataAnnotationsValidator for enabling data annotation validation and ValidationSummary for displaying all validation errors in one place. Children: validation components like DataAnnotationsValidator, ValidationSummary, etc.

Declaration

cs-api-definition
[Parameter]
public RenderFragment FormValidation { get; set; }

Property Value

RenderFragment

Id

Assigns a unique HTML id attribute to the form element for accessibility, testing, and DOM manipulation. Use this when you need to reference the form programmatically with JavaScript, associate it with external labels, or target it in CSS. The id should be unique within the page to maintain valid HTML and avoid conflicts with other elements. Common scenarios include form submission handling, automated testing selectors, and accessibility improvements.

Declaration

cs-api-definition
[Parameter]
public string Id { get; set; }

Property Value

string

Model

Specifies the data model object that the form will bind to and edit. When provided without FormItems, the form automatically generates input fields for all public properties using reflection and data annotations. Cannot be used together with EditContext - provide either Model or EditContext, not both. Use this for simple forms where automatic field generation is sufficient, such as editing a Person object with Name, Email, and Age properties.

Declaration

cs-api-definition
[Parameter]
public object Model { get; set; }

Property Value

object

OnInvalidSubmit

Handles failed form submissions when validation rules fail and the form contains invalid data. Automatically triggers after form submission if any field validation fails or validation errors exist. Use this to display error messages, highlight invalid fields, or prevent navigation when data is incomplete. Must be used together with OnValidSubmit when implementing automatic validation handling - cannot be combined with OnSubmit. The EditContext parameter contains validation error information that can be used to guide user corrections.

Declaration

cs-api-definition
[Parameter]
public EventCallback<EditContext> OnInvalidSubmit { get; set; }

Property Value

EventCallback<EditContext>

OnSubmit

Handles form submission events with full control over validation timing and custom submission logic. Fires whenever the form is submitted, regardless of validation state, allowing manual validation handling and custom workflows. Cannot be used together with OnValidSubmit and OnInvalidSubmit - choose either OnSubmit for manual control or the valid/invalid pair for automatic validation handling. Use this when you need to implement custom validation logic, multi-step submission processes, or integrate with external validation systems. The EditContext parameter provides access to the form's current state and validation information.

Declaration

cs-api-definition
[Parameter]
public EventCallback<EditContext> OnSubmit { get; set; }

Property Value

EventCallback<EditContext>

OnUpdate

Triggers whenever a form field value changes, providing real-time tracking of user input and form modifications. Use this for implementing auto-save functionality, live validation feedback, audit trails, or dynamic form behavior based on field changes. The FormUpdateEventArgs contains the changed field name and the updated model object for detailed change tracking. Fires for all field types including text inputs, dropdowns, checkboxes, and custom editors within the form. Ideal for scenarios requiring immediate response to user input without waiting for form submission.

Declaration

cs-api-definition
[Parameter]
public EventCallback<FormUpdateEventArgs> OnUpdate { get; set; }

Property Value

EventCallback<FormUpdateEventArgs>

OnValidSubmit

Handles successful form submissions when all validation rules pass and the form data is valid. Automatically triggers after form submission if all field validation succeeds and no validation errors exist. Use this for standard form processing like saving data to a database, calling APIs, or navigating to confirmation pages. Must be used together with OnInvalidSubmit when implementing automatic validation handling - cannot be combined with OnSubmit. The EditContext parameter contains the validated form data ready for processing.

Declaration

cs-api-definition
[Parameter]
public EventCallback<EditContext> OnValidSubmit { get; set; }

Property Value

EventCallback<EditContext>

Orientation

Controls the visual arrangement of form field labels relative to their input controls. Vertical (default) places labels above input fields, ideal for mobile-friendly layouts and narrow screens. Horizontal places labels beside input fields, saving vertical space and suitable for desktop layouts with wider screens. This setting affects the default ButtonsLayout behavior - horizontal orientation defaults to End, vertical defaults to Start.

Declaration

cs-api-definition
[Parameter]
public FormOrientation Orientation { get; set; }

Property Value

FormOrientation

RowSpacing

Controls the vertical spacing between rows in multi-column form grid layouts. Accepts any valid CSS length value such as "16px", "1rem", "2em", or "1%". Only takes effect when Columns is set to a value greater than 1 to enable grid layout. Use this to fine-tune the vertical rhythm of your form - larger values for more breathing room, smaller for compact layouts. When not specified, the browser uses default grid row spacing.

Declaration

cs-api-definition
[Parameter]
public string RowSpacing { get; set; }

Property Value

string

Size

Controls the overall visual size and spacing of form elements using predefined theme size constants. Use "small" for compact forms with tighter spacing, "medium" (default) for standard business applications, or "large" for enhanced accessibility and touch-friendly interfaces. This setting affects all form elements including labels, inputs, buttons, and spacing to maintain consistent visual hierarchy. The size value should match theme constants from ThemeConstants.Form.Size for proper theming integration.

Declaration

cs-api-definition
[Parameter]
public string Size { get; set; }

Property Value

string

ValidationMessageType

Controls how validation error messages are displayed to users when form fields contain invalid data. Inline (default) shows error messages directly below each invalid input field for immediate feedback. Tooltip displays error messages in tooltips when hovering over invalid fields, saving screen space. None hides individual field error messages, useful when showing only a ValidationSummary component.

Declaration

cs-api-definition
[Parameter]
public FormValidationMessageType ValidationMessageType { get; set; }

Property Value

FormValidationMessageType

Width

Sets the overall width of the form container using any valid CSS width value. Accepts values like "400px" for fixed pixel width, "100%" for full container width, "50vw" for viewport-relative width, or "auto" for content-based sizing. Use this to constrain form width for better readability on wide screens or to fit forms within specific layout requirements. When not specified, the form takes up the available width of its parent container.

Declaration

cs-api-definition
[Parameter]
public string Width { get; set; }

Property Value

string

Methods

BuildRenderTree(RenderTreeBuilder)

Declaration

cs-api-definition
protected override void BuildRenderTree(RenderTreeBuilder builder)

Parameters

builder

RenderTreeBuilder

Overrides ComponentBase.BuildRenderTree(RenderTreeBuilder)

IsValid()

Validates all form fields and returns whether the entire form contains valid data. Triggers validation for all fields and displays any validation error messages according to the ValidationMessageType setting. Use this method to programmatically check form validity before custom processing, such as enabling save buttons or performing complex business logic. Returns true when all fields pass their validation rules, false when any field contains invalid data or validation errors exist. This method does not submit the form - use it for validation checks without triggering submission events.

Declaration

cs-api-definition
public bool IsValid()

Returns

bool

OnParametersSet()

Declaration

cs-api-definition
protected override void OnParametersSet()

Overrides ComponentBase.OnParametersSet()

Refresh()

Forces the form component to re-render and update its visual state immediately. Use this method when form data or settings change programmatically and you need the UI to reflect those changes instantly. Common scenarios include updating form fields after external data changes, refreshing validation states, or responding to dynamic model updates. This method triggers a complete component refresh without affecting form validation or submission state.

Declaration

cs-api-definition
public void Refresh()

SetParametersAsync(ParameterView)

Declaration

cs-api-definition
public override Task SetParametersAsync(ParameterView parameters)

Parameters

parameters

ParameterView

Returns

Task

Overrides ComponentBase.SetParametersAsync(ParameterView)