ClassFormItem
Represents an individual form field component that handles data binding, validation, and editor rendering within Telerik Forms. Automatically selects appropriate input editors based on data types or allows explicit editor specification for custom data entry experiences. Use this component to define specific form fields with custom labels, hints, validation, and layout properties within FormItems or FormGroups. Supports various editor types including text inputs, date pickers, checkboxes, and switches with comprehensive validation integration.
Definition
Namespace:Telerik.Blazor.Components
Assembly:Telerik.Blazor.dll
Syntax:
public class FormItem : ComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IFormItem, IFormItemBase, IDisposable
Inheritance: objectComponentBaseFormItem
Implements:
Inherited Members
Constructors
FormItem()
Declaration
public FormItem()
Properties
Class
Adds custom CSS classes to the outermost container element of the form item for styling and layout customization. Use this to apply custom styling, responsive behavior, or framework-specific classes like Bootstrap utilities. Classes are added to the top-level form item wrapper, affecting the entire field including label, input, and validation areas. Multiple classes can be specified using space-separated values like "custom-field important-field". Ideal for implementing custom themes, conditional styling, or integrating with existing CSS frameworks.
Declaration
[Parameter]
public string Class { get; set; }
Property Value
Implements
ColSpan
Controls how many columns this form item spans in CSS Grid layouts when the parent form uses multi-column arrangement. Use values like 2 to make a field span two columns, 3 for three columns, etc., allowing flexible field sizing within grid layouts. Only effective when the parent TelerikForm or FormGroup has Columns set to enable grid layout. Useful for wide fields like addresses or comments that need more horizontal space than standard single-column fields. Default value of 0 means the field occupies one column in the grid layout.
Declaration
[Parameter]
public int ColSpan { get; set; }
Property Value
Implements
EditorType
Explicitly specifies which type of input editor to render for this form field, overriding automatic editor selection. TextBox renders a single-line text input for short text values. TextArea renders a multi-line text input for longer content like descriptions or comments. DatePicker renders a date selection control for date-only values. TimePicker renders a time selection control for time-only values. DateTimePicker renders a combined date and time selection control. Switch renders a toggle switch control for boolean values. CheckBox renders a checkbox control for boolean values. When not specified, the form automatically selects the most appropriate editor based on the field's data type and attributes.
Declaration
[Parameter]
public FormEditorType? EditorType { get; set; }
Property Value
Implements
Enabled
Controls whether the form field accepts user input and participates in form interactions. Set to false to create read-only fields that display data without allowing modification, useful for calculated fields or status displays. When disabled, the field appears visually dimmed and cannot receive focus or user input, but still participates in form validation and data binding. Automatically respects EditableAttribute settings from the model property when this parameter is not explicitly set. Use this for conditional editing scenarios, workflow-based forms, or fields that should be editable only under certain conditions.
Declaration
[Parameter]
public bool Enabled { get; set; }
Property Value
Implements
Field
Identifies which property from the form model this form item should bind to and edit. Use the exact property name from your model class, such as "FirstName", "DateOfBirth", or "IsActive". This field name is used for data binding, validation message association, and automatic editor type detection. Supports nested properties using dot notation like "Address.Street" or "Contact.Email" for complex object scenarios. Required for automatic form generation and proper two-way data binding with the form model.
Declaration
[Parameter]
public string Field { get; set; }
Property Value
Implements
FieldType
Explicitly specifies the data type for the form field when automatic type detection through reflection fails or is insufficient. Use this when working with complex generics, dynamic objects, or when you need to override the default editor selection. Common scenarios include nullable types that need specific handling, interfaces that require concrete type specification, or custom objects without clear property metadata. When not provided, the form automatically determines the field type using reflection on the Field property. This type information influences which editor component gets rendered and how validation rules are applied.
Declaration
[Parameter]
public Type FieldType { get; set; }
Property Value
Implements
Hint
Provides helpful guidance text that appears below the form input to assist users with data entry requirements. Use this for examples, format specifications, or additional context like "Enter phone number in format: (555) 123-4567". The hint is automatically hidden when the field has validation errors, allowing error messages to take priority. Ideal for complex fields that need explanation, password requirements, or formatting examples to improve user experience. Keep hints concise and actionable to provide value without cluttering the form interface.
Declaration
[Parameter]
public string Hint { get; set; }
Property Value
Implements
Id
Sets a unique HTML id attribute for the form input control to enable proper label association and accessibility. When not specified, a random GUID is automatically generated to ensure label-input association works correctly. Use custom IDs when you need to reference the input from external JavaScript, CSS styling, or automated testing tools. The ID should be unique within the page to maintain valid HTML structure and avoid conflicts with other form elements. This ID is automatically linked to the form label for improved screen reader support and accessibility compliance.
Declaration
[Parameter]
public string Id { get; set; }
Property Value
Implements
LabelText
Specifies the display text for the form field label that appears above or beside the input control. When provided, this label text takes precedence over any DisplayAttribute name defined on the model property. Use descriptive labels like "Full Name", "Email Address", or "Phone Number" to clearly identify the field purpose. Leave empty to hide the label entirely, or use the model property's DisplayAttribute when this parameter is not set. Support for HTML content allows rich formatting, but ensure accessibility by keeping labels clear and concise.
Declaration
[Parameter]
public string LabelText { get; set; }
Property Value
Implements
Template
Replaces the entire form item rendering with completely custom content, bypassing automatic label, editor, and validation generation. Use this for complex custom layouts, specialized input combinations, or when integrating third-party components that don't fit standard form patterns. When Template is provided, the form item renders only your custom content - no automatic labels, editors, or validation messages are generated. The template has full access to the form's EditContext and model data for implementing custom data binding and validation display. Ideal for scenarios requiring unique layouts, composite controls, or specialized user interface elements not supported by standard form items.
Declaration
[Parameter]
public RenderFragment Template { get; set; }
Property Value
Implements
Methods
BuildRenderTree(RenderTreeBuilder)
Declaration
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
__builder
Overrides
Dispose()
Declaration
public void Dispose()
Implements
OnInitialized()
Declaration
protected override void OnInitialized()
Overrides
SetParametersAsync(ParameterView)
Declaration
public override Task SetParametersAsync(ParameterView parameters)
Parameters
parameters
Returns
Overrides