New to Telerik UI for ASP.NET Core? Start a free 30-day trial

Defines the fluent API for configuring the Kendo UI Form

Definition

Namespace:Kendo.Mvc.UI.Fluent

Assembly:Kendo.Mvc.dll

Type Parameters:

T

Syntax:

C#
public class FormBuilder<T> : WidgetBuilderBase<Form<T>, FormBuilder<T>>, IHtmlContent

Inheritance: objectHelperResultWidgetBuilderBase<Form<T>, FormBuilder<T>>FormBuilder<T>

Implements: IHtmlContent

Inherited Members WidgetBuilderBase<Form<T>, FormBuilder<T>>.ToComponent()WidgetBuilderBase<Form<T>, FormBuilder<T>>.Expression(string)WidgetBuilderBase<Form<T>, FormBuilder<T>>.Explorer(ModelExplorer)WidgetBuilderBase<Form<T>, FormBuilder<T>>.Name(string)WidgetBuilderBase<Form<T>, FormBuilder<T>>.Deferred(bool)WidgetBuilderBase<Form<T>, FormBuilder<T>>.HtmlAttributes(object)WidgetBuilderBase<Form<T>, FormBuilder<T>>.HtmlAttributes(IDictionary<string, object>)WidgetBuilderBase<Form<T>, FormBuilder<T>>.ScriptAttributes(object, bool)WidgetBuilderBase<Form<T>, FormBuilder<T>>.ScriptAttributes(IDictionary<string, object>, bool)WidgetBuilderBase<Form<T>, FormBuilder<T>>.Render()WidgetBuilderBase<Form<T>, FormBuilder<T>>.ToHtmlString()WidgetBuilderBase<Form<T>, FormBuilder<T>>.WriteTo(TextWriter, HtmlEncoder)WidgetBuilderBase<Form<T>, FormBuilder<T>>.ToClientTemplate()WidgetBuilderBase<Form<T>, FormBuilder<T>>.AsModule(bool)WidgetBuilderBase<Form<T>, FormBuilder<T>>.ComponentWidgetBuilderBase<Form<T>, FormBuilder<T>>.ContainerHelperResult.WriteTo(TextWriter, HtmlEncoder)HelperResult.WriteActionobject.GetType()object.MemberwiseClone()object.ToString()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()...

Constructors

Initializes a new instance of the FormBuilder<T> class.

C#
public FormBuilder(Form<T> component)
Parameters:componentForm<T>

Methods

Specifies the template which is used for rendering the From buttons.

C#
public FormBuilder<T> ButtonsTemplate(string value)
Parameters:valuestring

The value that configures the buttons template.

Returns:

FormBuilder<T>

A FormBuilder<T> instance that can be used to configure the Form.

Example:
C#
@(Html.Kendo().Form()
.Name("form")
.ButtonsTemplate("Update Data")
)

Specifies the template which is used for rendering the From buttons.

C#
public FormBuilder<T> ButtonsTemplate<TModel>(TemplateBuilder<TModel> template)
Parameters:templateTemplateBuilder<TModel>

The value that configures the buttons template.

Returns:

FormBuilder<T>

A FormBuilder<T> instance that can be used to configure the Form.

Example:
C#
@(Html.Kendo().Form()
.Name("form")
.ButtonsTemplate(Html.Kendo().Template().AddHtml("Submit"))
)

Specifies the template which is used for rendering the From buttons.

C#
public FormBuilder<T> ButtonsTemplateId(string value)
Parameters:valuestring

The value that configures the buttons template.

Returns:

FormBuilder<T>

A FormBuilder<T> instance that can be used to configure the Form.

Example:
C#
@(Html.Kendo().Form()
.Name("form")
.ButtonsTemplateId("buttonsClientTemplate")
)

Specifies the template which is used for rendering the From buttons.

C#
public FormBuilder<T> ButtonsTemplateView(IHtmlContent templateView)
Parameters:templateViewIHtmlContentReturns:

FormBuilder<T>

A FormBuilder<T> instance that can be used to configure the Form.

Example:
C#
@(Html.Kendo().Form()
.Name("form")
.ButtonsTemplate("templateView")
)

Specifies if the clearButton should be rendered on initialization.

C#
public FormBuilder<T> ClearButton(bool value)
Parameters:valuebool

The value that configures the clearbutton.

Returns:

FormBuilder<T>

A FormBuilder<T> instance that can be used to configure the Form.

Example:
C#
@(Html.Kendo().Form()
.Name("form")
.ClearButton(false)
)

Configures the client-side events.

C#
public FormBuilder<T> Events(Action<FormEventBuilder> configurator)
Parameters:configuratorAction<FormEventBuilder>

The client events action.

Returns:

FormBuilder<T>

A FormBuilder<T> instance that can be used to configure the Form.

Example:
C#
@( Html.Kendo().Form()
.Name("Form")
.Events(events =&gt; events
.Validate("onValidate")
)
)

Specifies if the first editor of the form will be focused on initialization.

C#
public FormBuilder<T> FocusFirst(bool value)
Parameters:valuebool

The value that configures the focus first.

Returns:

FormBuilder<T>

A FormBuilder<T> instance that can be used to configure the Form.

Example:
C#
@(Html.Kendo().Form()
.Name("form")
.FocusFirst(true)
)

Callback function that could be used to change the default format of the automatically generated labels. Takes effect only if the Items option is not specified and labels are being automatically generated.

C#
public FormBuilder<T> FormatLabel(Func<object, object> handler)
Parameters:handlerFunc<object, object>

The value that configures the formatlabel action.

Returns:

FormBuilder<T>

A FormBuilder<T> instance that can be used to configure the Form.

Example:
C#
@(Html.Kendo().Form&lt;Kendo.Mvc.Examples.Models.Form.FormItemsViewModels&gt;()
.Name("form")
.FormatLabel(@&lt;text&gt;
function(field){
return field + ":";
}
&lt;/text&gt;)
)

Callback function that could be used to change the default format of the automatically generated labels.

C#
public FormBuilder<T> FormatLabel(string handler)
Parameters:handlerstring

The value that configures the formatlabel action.

Returns:

FormBuilder<T>

A FormBuilder<T> instance that can be used to configure the Form.

Example:
C#
@(Html.Kendo().Form&lt;Kendo.Mvc.Examples.Models.Form.FormItemsViewModels&gt;()
.Name("form")
.FormatLabel("formatLabelHandler")
)

An object that provides the initial data for the Form.

C#
public FormBuilder<T> FormData(object value)
Parameters:valueobject

The data model object.

Returns:

FormBuilder<T>

A FormBuilder<T> instance that can be used to configure the Form.

Example:
C#
@(Html.Kendo().Form&lt;Kendo.Mvc.Examples.Models.Form.FormItemsViewModels&gt;()
.Name("form")
.FormData(
new FormItemsViewModels
{
UserId = 42,
FirstName = "Antony",
Password = null
})
)

Grid layout settings.

C#
public FormBuilder<T> Grid(Action<FormGridSettingsBuilder<T>> configurator)
Parameters:configuratorAction<FormGridSettingsBuilder<T>>

The action that configures the grid.

Returns:

FormBuilder<T>

A FormBuilder<T> instance that can be used to configure the Form.

Example:
C#
@(Html.Kendo().Form&lt;Kendo.Mvc.Examples.Models.Form.FormItemsViewModels&gt;()
.Name("form")
.Layout("grid")
.Grid(g =&gt; g.Cols(2).Gutter(20))
)

A JavaScript array that contains the Form's items configuration.

C#
public FormBuilder<T> Items(Action<FormItemFactory<T>> configurator)
Parameters:configuratorAction<FormItemFactory<T>>

The action that configures the items.

Returns:

FormBuilder<T>

A FormBuilder<T> instance that can be used to configure the Form.

Example:
C#
@(Html.Kendo().Form&lt;Kendo.Mvc.Examples.Models.Form.FormItemsViewModels&gt;()
.Name("form")
.Items(items =&gt;
{
items.AddGroup()
.Label("Sign up form")
.Items(i =&gt;
{
i.Add()
.Field(f =&gt; f.UserID)
.Editor(editor =&gt; editor.Hidden());
i.Add()
.Field(f =&gt; f.FirstName)
.Label(l =&gt; l.Text("First Name:"));
i.Add()
.Field(f =&gt; f.Password)
.Label(l =&gt; l.Text("Password:"))
.Hint("Hint: enter alphanumeric characters only.")
.EditorTemplateHandler("setPasswordEditor");
i.Add()
.Field(f =&gt; f.ComboBox)
.Label(l =&gt; l.Text("ComboBox:").Optional(true))
.Editor(e =&gt;
{
e.ComboBox()
.Filter(FilterType.Contains)
.MinLength(3)
.Placeholder("Select...")
.DataTextField("ProductName")
.DataValueField("ProductID")
.Height(520)
.DataSource(source =&gt;
{
source.Read(read =&gt;
{
read.Action("Items_GetProducts", "Form").Data("filterProducts");
})
.ServerFiltering(true);
});
});
})
})
)

Specify the layout of Form content. Valid options are: grid: This is equivalent to display: grid. It defines the form element as a grid container and establishes a new grid formatting context for its contents..

C#
public FormBuilder<T> Layout(string value)
Parameters:valuestring

The value that configures the layout.

Returns:

FormBuilder<T>

A FormBuilder<T> instance that can be used to configure the Form.

Example:
C#
@(Html.Kendo().Form&lt;Kendo.Mvc.Examples.Models.Form.FormItemsViewModels&gt;()
.Name("form")
.Layout("grid")
.Grid(g =&gt; g.Cols(2).Gutter(20))
)

Configures text messages displayed in the Form. Use it to customize or localize the Form messages..

C#
public FormBuilder<T> Messages(Action<FormMessagesSettingsBuilder<T>> configurator)
Parameters:configuratorAction<FormMessagesSettingsBuilder<T>>

The action that configures the messages.

Returns:

FormBuilder<T>

A FormBuilder<T> instance that can be used to configure the Form.

Example:
C#
@(Html.Kendo().Form&lt;Kendo.Mvc.Examples.Models.Form.FormItemsViewModels&gt;()
.Name("form")
.Messages(messages=&gt;{
messages.Submit("Custom Submit Button Text");
messages.Clear("Custom Clear Button Text");
messages.Optional("(Optional field)");
})
)

Configures the Form orientation. Available options are "horizontal" and "vertical".By default, the Form is rendered with vertical orientation.

C#
public FormBuilder<T> Orientation(string value)
Parameters:valuestring

The value that configures the orientation.

Returns:

FormBuilder<T>

A FormBuilder<T> instance that can be used to configure the Form.

Example:
C#
@(Html.Kendo().Form()
.Name("form")
.Orientation("horizontal")
)

Sets a value controlling the size of the input.

C#
public FormBuilder<T> Size(ComponentSize? value)
Parameters:valueComponentSize?

The value for Size

Returns:

FormBuilder<T>

A FormBuilder<T> instance that can be used to configure the Form.

Configures the SmartPasteButton integration for AI-powered form filling. When enabled, adds a SmartPasteButton that can intelligently parse clipboard content and distribute it to appropriate form fields using AI processing.

C#
public FormBuilder<T> SmartPaste(Action<SmartPasteButtonBuilder> configurator)
Parameters:configuratorAction<SmartPasteButtonBuilder>

The action that configures the smartpaste.

Returns:

FormBuilder<T>

Configures the built-in Validator options.

C#
public FormBuilder<T> Validatable(Action<FormValidatableSettingsBuilder<T>> configurator)
Parameters:configuratorAction<FormValidatableSettingsBuilder<T>>

The action that configures the validatable.

Returns:

FormBuilder<T>

A FormBuilder<T> instance that can be used to configure the Form.

Example:
C#
@(Html.Kendo().Form()
.Name("form")
.Validatable(v =&gt;
{
v.ValidateOnBlur(true);
v.ValidationSummary(vs =&gt; vs.Enable(false));
})
)