Class DefaultFieldGenerator<TModel, T>
The default field HTML generator.
Inheritance
Inherited Members
Namespace: ChameleonForms.FieldGenerators
Assembly: ChameleonForms.dll
Syntax
public class DefaultFieldGenerator<TModel, T> : IFieldGenerator<TModel, T>, IFieldGenerator
Type Parameters
Name | Description |
---|---|
TModel | The type of the view model for the form |
T | The type of the field being generated |
Constructors
| Improve this Doc View SourceDefaultFieldGenerator(IHtmlHelper<TModel>, Expression<Func<TModel, T>>, IFormTemplate)
Constructs the field generator.
Declaration
public DefaultFieldGenerator(IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, T>> fieldProperty, IFormTemplate template)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> | htmlHelper | The HTML helper for the current view |
System.Linq.Expressions.Expression<System.Func<TModel, T>> | fieldProperty | Expression to identify the property to generate the field for |
IFormTemplate | template | The template being used to output the form |
Properties
| Improve this Doc View SourceFieldProperty
The expression that identifies the property in the model being output.
Declaration
public Expression<Func<TModel, T>> FieldProperty { get; }
Property Value
Type | Description |
---|---|
System.Linq.Expressions.Expression<System.Func<TModel, T>> |
HtmlHelper
A HTML helper for the model.
Declaration
public IHtmlHelper<TModel> HtmlHelper { get; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> |
Metadata
The metadata for the form field.
Declaration
public ModelMetadata Metadata { get; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata |
Template
The form template that will be used to render the form.
Declaration
public IFormTemplate Template { get; }
Property Value
Type | Description |
---|---|
IFormTemplate |
Methods
| Improve this Doc View SourceGetCustomAttributes()
Returns any custom attributes against the field being generated.
Declaration
public IEnumerable<Attribute> GetCustomAttributes()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Attribute> | The attributes |
GetFieldDisplayName()
Returns the displayable name of the field being generated.
Declaration
public string GetFieldDisplayName()
Returns
Type | Description |
---|---|
System.String | The id |
GetFieldHtml(IFieldConfiguration)
Creates the HTML for the field control after preparing the given field configuration.
Declaration
public IHtmlContent GetFieldHtml(IFieldConfiguration fieldConfiguration)
Parameters
Type | Name | Description |
---|---|---|
IFieldConfiguration | fieldConfiguration |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Html.IHtmlContent | The HTML for the field control |
GetFieldHtml(IReadonlyFieldConfiguration)
Creates the HTML for the field control.
Declaration
public IHtmlContent GetFieldHtml(IReadonlyFieldConfiguration fieldConfiguration)
Parameters
Type | Name | Description |
---|---|---|
IReadonlyFieldConfiguration | fieldConfiguration |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Html.IHtmlContent | The HTML for the field control |
GetFieldId()
Returns the id of the field being generated.
Declaration
public string GetFieldId()
Returns
Type | Description |
---|---|
System.String | The id |
GetLabelHtml(IFieldConfiguration)
Creates the HTML for the field label after preparing the given field configuration.
Declaration
public IHtmlContent GetLabelHtml(IFieldConfiguration fieldConfiguration)
Parameters
Type | Name | Description |
---|---|---|
IFieldConfiguration | fieldConfiguration |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Html.IHtmlContent | The HTML for the field label |
GetLabelHtml(IReadonlyFieldConfiguration)
Creates the HTML for the field label.
Declaration
public IHtmlContent GetLabelHtml(IReadonlyFieldConfiguration fieldConfiguration)
Parameters
Type | Name | Description |
---|---|---|
IReadonlyFieldConfiguration | fieldConfiguration |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Html.IHtmlContent | The HTML for the field label |
GetModel()
Returns a model with the current values for the form.
Declaration
public TModel GetModel()
Returns
Type | Description |
---|---|
TModel | The current model |
GetValidationHtml(IFieldConfiguration)
Creates the HTML for the field's validation messages after preparing the given field configuration.
Declaration
public IHtmlContent GetValidationHtml(IFieldConfiguration fieldConfiguration)
Parameters
Type | Name | Description |
---|---|---|
IFieldConfiguration | fieldConfiguration |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Html.IHtmlContent | The HTML for the field's validation messages |
GetValidationHtml(IReadonlyFieldConfiguration)
Creates the HTML for the field's validation messages
Declaration
public IHtmlContent GetValidationHtml(IReadonlyFieldConfiguration fieldConfiguration)
Parameters
Type | Name | Description |
---|---|---|
IReadonlyFieldConfiguration | fieldConfiguration |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Html.IHtmlContent | The HTML for the field's validation messages |
GetValue()
Returns the current value of the field.
Declaration
public T GetValue()
Returns
Type | Description |
---|---|
T | The current field value |
PrepareFieldConfiguration(IFieldConfiguration, FieldParent)
Turns the given IFieldConfiguration into a FieldConfiguration ready to use for generating the form field.
Declaration
public IReadonlyFieldConfiguration PrepareFieldConfiguration(IFieldConfiguration fieldConfiguration, FieldParent fieldParent)
Parameters
Type | Name | Description |
---|---|---|
IFieldConfiguration | fieldConfiguration | The field configuration to modify |
FieldParent | fieldParent | The parent component of the field |
Returns
Type | Description |
---|---|
IReadonlyFieldConfiguration | The readonly field configuration; ready for generating the form field |