Table of Contents

Class FormExtensions

Namespace
Kentico.Forms.Web.Mvc
Assembly
Kentico.Content.Web.Mvc.dll

Contains helper methods for rendering HTML for forms built using Form builder.

public static class FormExtensions
Inheritance
object
FormExtensions

Methods

BeginWrappingElement(HtmlHelperExtensionPoint, ElementRenderingConfiguration)

Renders the start tag of wrapping HTML element based on configuration. An empty string is returned, when configuration is null or does not specify an ElementName.

public static IHtmlContent BeginWrappingElement(this HtmlHelperExtensionPoint htmlHelper, ElementRenderingConfiguration configuration = null)

Parameters

htmlHelper HtmlHelperExtensionPoint

HtmlHelper extension.

configuration ElementRenderingConfiguration

Configuration object for the wrapping element.

Returns

IHtmlContent

Returns start tag of wrapping HTML element or an empty string.

Exceptions

ArgumentNullException

Thrown when htmlHelper is null.

InvalidOperationException

Thrown when CustomHtmlString is used but CONTENT_PLACEHOLDER is missing.

EditorAsync(HtmlHelperExtensionPoint, FormComponent, IDictionary<string, object>)

Returns an HTML editing element for given formComponent.

public static Task<IHtmlContent> EditorAsync(this HtmlHelperExtensionPoint htmlHelper, FormComponent formComponent, IDictionary<string, object> htmlAttributes = null)

Parameters

htmlHelper HtmlHelperExtensionPoint

HtmlHelper extension.

formComponent FormComponent

The form component to render the editing element for.

htmlAttributes IDictionary<string, object>

An object containing additional HTML attributes for the editor.

Returns

Task<IHtmlContent>

An HTML editing element for form component.

Exceptions

ArgumentNullException

Thrown when htmlHelper or formComponent is null.

ArgumentException

Thrown when Name of the form component passed is null or an empty string.

EndWrappingElement(HtmlHelperExtensionPoint, ElementRenderingConfiguration)

Renders the end tag of wrapping HTML element based on configuration. An empty string is returned, when configuration is null or does not specify an ElementName.

public static IHtmlContent EndWrappingElement(this HtmlHelperExtensionPoint htmlHelper, ElementRenderingConfiguration configuration = null)

Parameters

htmlHelper HtmlHelperExtensionPoint

HtmlHelper extension.

configuration ElementRenderingConfiguration

Configuration object for the wrapping element.

Returns

IHtmlContent

Returns end tag of wrapping HTML element or an empty string.

Exceptions

ArgumentNullException

Thrown when htmlHelper is null.

InvalidOperationException

Thrown when CustomHtmlString is used but CONTENT_PLACEHOLDER is missing.

FormFieldAsync(HtmlHelperExtensionPoint, FormComponent, FormFieldRenderingConfiguration)

Returns HTML markup for given formComponent. The markup contains a label and an editing element representing the form component given.

public static Task<IHtmlContent> FormFieldAsync(this HtmlHelperExtensionPoint htmlHelper, FormComponent formComponent, FormFieldRenderingConfiguration renderingConfiguration = null)

Parameters

htmlHelper HtmlHelperExtensionPoint

HtmlHelper extension.

formComponent FormComponent

The form component to render the markup for.

renderingConfiguration FormFieldRenderingConfiguration

Configuration for the form field rendering. If null, Default is used.

Returns

Task<IHtmlContent>

HTML markup for form component.

Exceptions

ArgumentNullException

Thrown when htmlHelper or formComponent is null.

FormFieldsAsync(HtmlHelperExtensionPoint, IEnumerable<FormComponent>, FormFieldRenderingConfiguration)

Returns HTML markup for given enumeration of form components. The markup contains a label and an editing element representing each of the form components.

public static Task<IHtmlContent> FormFieldsAsync(this HtmlHelperExtensionPoint htmlHelper, IEnumerable<FormComponent> formComponents, FormFieldRenderingConfiguration renderingConfiguration = null)

Parameters

htmlHelper HtmlHelperExtensionPoint

HtmlHelper extension.

formComponents IEnumerable<FormComponent>

The form components to render the markup for.

renderingConfiguration FormFieldRenderingConfiguration

Configuration for the form fields rendering. If null, Default is used.

Returns

Task<IHtmlContent>

HTML markup for form component.

Exceptions

ArgumentNullException

Thrown when htmlHelper or formComponents is null.

Label(HtmlHelperExtensionPoint, FormComponent, IDictionary<string, object>, bool)

Returns an HTML label element for given formComponent.

public static IHtmlContent Label(this HtmlHelperExtensionPoint htmlHelper, FormComponent formComponent, IDictionary<string, object> htmlAttributes = null, bool renderColon = true)

Parameters

htmlHelper HtmlHelperExtensionPoint

HtmlHelper extension.

formComponent FormComponent

The form component to render the label for.

htmlAttributes IDictionary<string, object>

An object containing additional HTML attributes for the label.

renderColon bool

Indicates whether a colon is to be rendered after the label text. If a label text is missing then colon is not rendered.

Returns

IHtmlContent

An HTML label element for form component.

Exceptions

ArgumentNullException

Thrown when htmlHelper or formComponent is null.

ArgumentException

Thrown when Name of the form component passed is null or an empty string.

SmartFieldIcon(HtmlHelperExtensionPoint, FormComponent, IDictionary<string, object>)

Returns a smart field icon if provided formComponent is a smart field.

public static IHtmlContent SmartFieldIcon(this HtmlHelperExtensionPoint htmlHelper, FormComponent formComponent, IDictionary<string, object> htmlAttributes = null)

Parameters

htmlHelper HtmlHelperExtensionPoint

HtmlHelper extension.

formComponent FormComponent

The form component to render the icon for.

htmlAttributes IDictionary<string, object>

An object containing additional HTML attributes for the icon.

Returns

IHtmlContent

An HTML editing element for smart field icon.

Exceptions

ArgumentNullException

Thrown when htmlHelper or formComponent is null.

ValidationSummary(HtmlHelperExtensionPoint, IEnumerable<FormComponent>)

Renders a validation summary for a form with clickable labels.

public static IHtmlContent ValidationSummary(this HtmlHelperExtensionPoint htmlHelper, IEnumerable<FormComponent> formComponents)

Parameters

htmlHelper HtmlHelperExtensionPoint

HtmlHelper extension.

formComponents IEnumerable<FormComponent>

Components contained a form for which the summary is rendered.

Returns

IHtmlContent

Validation summary markup.