Class FormExtensions
Contains helper methods for rendering HTML for forms built using Form builder.
public static class FormExtensions
- Inheritance
-
objectFormExtensions
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
htmlHelperHtmlHelperExtensionPointHtmlHelper extension.
configurationElementRenderingConfigurationConfiguration object for the wrapping element.
Returns
- IHtmlContent
Returns start tag of wrapping HTML element or an empty string.
Exceptions
- ArgumentNullException
Thrown when
htmlHelperis 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
htmlHelperHtmlHelperExtensionPointHtmlHelper extension.
formComponentFormComponentThe form component to render the editing element for.
htmlAttributesIDictionary<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
htmlHelperorformComponentis 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
htmlHelperHtmlHelperExtensionPointHtmlHelper extension.
configurationElementRenderingConfigurationConfiguration object for the wrapping element.
Returns
- IHtmlContent
Returns end tag of wrapping HTML element or an empty string.
Exceptions
- ArgumentNullException
Thrown when
htmlHelperis 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
htmlHelperHtmlHelperExtensionPointHtmlHelper extension.
formComponentFormComponentThe form component to render the markup for.
renderingConfigurationFormFieldRenderingConfigurationConfiguration for the form field rendering. If null, Default is used.
Returns
- Task<IHtmlContent>
HTML markup for form component.
Exceptions
- ArgumentNullException
Thrown when
htmlHelperorformComponentis 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
htmlHelperHtmlHelperExtensionPointHtmlHelper extension.
formComponentsIEnumerable<FormComponent>The form components to render the markup for.
renderingConfigurationFormFieldRenderingConfigurationConfiguration for the form fields rendering. If null, Default is used.
Returns
- Task<IHtmlContent>
HTML markup for form component.
Exceptions
- ArgumentNullException
Thrown when
htmlHelperorformComponentsis 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
htmlHelperHtmlHelperExtensionPointHtmlHelper extension.
formComponentFormComponentThe form component to render the label for.
htmlAttributesIDictionary<string, object>An object containing additional HTML attributes for the label.
renderColonboolIndicates 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
htmlHelperorformComponentis 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
htmlHelperHtmlHelperExtensionPointHtmlHelper extension.
formComponentFormComponentThe form component to render the icon for.
htmlAttributesIDictionary<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
htmlHelperorformComponentis 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
htmlHelperHtmlHelperExtensionPointHtmlHelper extension.
formComponentsIEnumerable<FormComponent>Components contained a form for which the summary is rendered.
Returns
- IHtmlContent
Validation summary markup.