Class Form<TModel>
Default Chameleon Form implementation.
Inheritance
Inherited Members
Namespace: ChameleonForms
Assembly: ChameleonForms.dll
Syntax
public class Form<TModel> : IForm<TModel>, IForm, IDisposable
Type Parameters
Name | Description |
---|---|
TModel |
Constructors
| Improve this Doc View SourceForm(IHtmlHelper<TModel>, IFormTemplate, String, FormMethod, HtmlAttributes, Nullable<EncType>, Nullable<Boolean>)
Construct a Chameleon Form. Note: Contains a call to the virtual method Write.
Declaration
public Form(IHtmlHelper<TModel> helper, IFormTemplate template, string action, FormMethod method, HtmlAttributes htmlAttributes, EncType? enctype, bool? outputAntiforgeryToken)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> | helper | The HTML Helper for the current view |
IFormTemplate | template | A template renderer instance to use to render the form |
System.String | action | The action the form should submit to |
Microsoft.AspNetCore.Mvc.Rendering.FormMethod | method | The HTTP method the form submission should use |
HtmlAttributes | htmlAttributes | Any HTML attributes the form should use expressed as an anonymous object |
System.Nullable<EncType> | enctype | The encoding type the form submission should use |
System.Nullable<System.Boolean> | outputAntiforgeryToken | Whether or not to output an antiforgery token in the form; defaults to null which will output a token if the method isn't GET |
Properties
| Improve this Doc View SourceHtmlHelper
The HTML helper for the current view.
Declaration
public IHtmlHelper<TModel> HtmlHelper { get; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> |
Template
The template renderer for the current view.
Declaration
public IFormTemplate Template { get; }
Property Value
Type | Description |
---|---|
IFormTemplate |
Methods
| Improve this Doc View SourceCreatePartialForm(IHtmlHelper<TModel>)
Returns a wrapped ChameleonForms.PartialViewForm`1 for the given partial view helper.
Declaration
public IForm<TModel> CreatePartialForm(IHtmlHelper<TModel> partialViewHelper)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> | partialViewHelper | The HTML Helper from the partial view |
Returns
Type | Description |
---|---|
IForm<TModel> | The PartialViewForm wrapping the original form |
CreatePartialForm<TPartialModel>(LambdaExpression, IHtmlHelper<TPartialModel>)
Returns a wrapped ChameleonForms.PartialViewForm`2 for the given partial view information.
Declaration
public IForm<TPartialModel> CreatePartialForm<TPartialModel>(LambdaExpression partialModelExpression, IHtmlHelper<TPartialModel> partialViewHelper)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.LambdaExpression | partialModelExpression | The expression that identifies the partial model |
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TPartialModel> | partialViewHelper | The HTML Helper from the partial view |
Returns
Type | Description |
---|---|
IForm<TPartialModel> | The PartialViewForm wrapping the original form |
Type Parameters
Name | Description |
---|---|
TPartialModel | The model type of the partial view |
Dispose()
Called when form is created within a using
block: writes the end tag of the form.
Declaration
public void Dispose()
GetFieldGenerator<T>(Expression<Func<TModel, T>>)
The field generator for the given field.
Declaration
public virtual IFieldGenerator GetFieldGenerator<T>(Expression<Func<TModel, T>> property)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<TModel, T>> | property | The property to return the field generator for |
Returns
Type | Description |
---|---|
IFieldGenerator |
Type Parameters
Name | Description |
---|---|
T |
Write(IHtmlContent)
Writes a HTML String directly to the view's output.
Declaration
public virtual void Write(IHtmlContent htmlContent)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.AspNetCore.Html.IHtmlContent | htmlContent | The HTML to write to the view's output |