Class FieldGeneratorHandler<TModel, T>
Base class that contains common logic for implementing field generator handlers.
Inheritance
Implements
Inherited Members
Namespace: ChameleonForms.FieldGenerators.Handlers
Assembly: ChameleonForms.dll
Syntax
public abstract class FieldGeneratorHandler<TModel, T> : IFieldGeneratorHandler<TModel, T>
Type Parameters
Name | Description |
---|---|
TModel | The type of the model the form is being output for |
T | The type of the property in the model that the specific field is being output for |
Constructors
| Improve this Doc View SourceFieldGeneratorHandler(IFieldGenerator<TModel, T>)
Create a field generator handler.
Declaration
protected FieldGeneratorHandler(IFieldGenerator<TModel, T> fieldGenerator)
Parameters
Type | Name | Description |
---|---|---|
IFieldGenerator<TModel, T> | fieldGenerator | The field generator to use |
Fields
| Improve this Doc View SourceFieldGenerator
The field generator for the current field.
Declaration
protected readonly IFieldGenerator<TModel, T> FieldGenerator
Field Value
Type | Description |
---|---|
IFieldGenerator<TModel, T> |
Methods
| Improve this Doc View SourceAdjustHtmlForModelState(HtmlAttributes)
Adjust the HTML attributes of a field based on the state of the model for that field. e.g. add validation attributes and error attributes.
Declaration
protected void AdjustHtmlForModelState(HtmlAttributes attrs)
Parameters
Type | Name | Description |
---|---|---|
HtmlAttributes | attrs | The attributes to modify |
CanHandle()
Whether or not the current field can be output using this field generator handler.
Declaration
public abstract bool CanHandle()
Returns
Type | Description |
---|---|
System.Boolean |
GenerateFieldHtml(IReadonlyFieldConfiguration)
Generate the HTML for the current field's Field Element using this handler.
Declaration
public abstract IHtmlContent GenerateFieldHtml(IReadonlyFieldConfiguration fieldConfiguration)
Parameters
Type | Name | Description |
---|---|---|
IReadonlyFieldConfiguration | fieldConfiguration | The field configuration to use to generate the HTML |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Html.IHtmlContent | The HTML for the Field Element |
GetDisplayType(IReadonlyFieldConfiguration)
The type of control the field will be displayed as.
Declaration
public abstract FieldDisplayType GetDisplayType(IReadonlyFieldConfiguration fieldConfiguration)
Parameters
Type | Name | Description |
---|---|---|
IReadonlyFieldConfiguration | fieldConfiguration | The configuration for the field |
Returns
Type | Description |
---|---|
FieldDisplayType | The display type of the field control |
GetFieldName()
The value to use for the full HTML name of the field.
Declaration
protected string GetFieldName()
Returns
Type | Description |
---|---|
System.String | The full HTML name of the field |
GetInputHtml(TextInputType, IReadonlyFieldConfiguration)
Returns HTML for an <input> HTML element.
Declaration
protected IHtmlContent GetInputHtml(TextInputType inputType, IReadonlyFieldConfiguration fieldConfiguration)
Parameters
Type | Name | Description |
---|---|---|
TextInputType | inputType | The type of input to produce |
IReadonlyFieldConfiguration | fieldConfiguration | The field configuration to use for attributes and format string |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Html.IHtmlContent | The HTML of the input element |
GetSelectListHtml(IEnumerable<SelectListItem>, IReadonlyFieldConfiguration)
Returns the HTML of a <select> list element. Automatically adds an empty item where appropriate.
Declaration
protected IHtmlContent GetSelectListHtml(IEnumerable<SelectListItem> selectList, IReadonlyFieldConfiguration fieldConfiguration)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> | selectList | The list of items to choose from in the select list |
IReadonlyFieldConfiguration | fieldConfiguration | The field configuration to use for attributes and empty item configuration |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Html.IHtmlContent |
PrepareFieldConfiguration(IFieldConfiguration)
Modify the field configuration for the field using this field generator handler.
Declaration
public virtual void PrepareFieldConfiguration(IFieldConfiguration fieldConfiguration)
Parameters
Type | Name | Description |
---|---|---|
IFieldConfiguration | fieldConfiguration | The field configuration to modify |