Class FieldExtensions
Extension methods for the creation of form fields, labels and validation messages.
Inheritance
Inherited Members
Namespace: ChameleonForms.Component
Assembly: ChameleonForms.dll
Syntax
public static class FieldExtensions
Methods
| Improve this Doc View SourceBeginFieldFor<TModel, T>(ISection<TModel>, Expression<Func<TModel, T>>, IFieldConfiguration)
Creates a single form field as a child of a form section that can have other form fields nested within it.
Declaration
public static Field<TModel> BeginFieldFor<TModel, T>(this ISection<TModel> section, Expression<Func<TModel, T>> property, IFieldConfiguration config = null)
Parameters
Type | Name | Description |
---|---|---|
ISection<TModel> | section | The section the field is being created in |
System.Linq.Expressions.Expression<System.Func<TModel, T>> | property | A lamdba expression to identify the field to render the field for |
IFieldConfiguration | config | Any configuration information for the field |
Returns
Type | Description |
---|---|
Field<TModel> | The form field |
Type Parameters
Name | Description |
---|---|
TModel | The view model type for the current view |
T | The type of the field being generated |
Examples
@using (var f = s.BeginFieldFor(m => m.Company)) { @f.FieldFor(m => m.PositionTitle) }
| Improve this Doc View SourceFieldElementFor<TModel, T>(IForm<TModel>, Expression<Func<TModel, T>>, IFieldConfiguration)
Creates a standalone form field to be output in a form.
Declaration
public static IFieldConfiguration FieldElementFor<TModel, T>(this IForm<TModel> form, Expression<Func<TModel, T>> property, IFieldConfiguration config = null)
Parameters
Type | Name | Description |
---|---|---|
IForm<TModel> | form | The form the field is being created in |
System.Linq.Expressions.Expression<System.Func<TModel, T>> | property | A lamdba expression to identify the field to render the field for |
IFieldConfiguration | config | Optional base field configuration |
Returns
Type | Description |
---|---|
IFieldConfiguration | A field configuration object that allows you to configure the field |
Type Parameters
Name | Description |
---|---|
TModel | The view model type for the current view |
T | The type of the field being generated |
Examples
@using (var f = Html.BeginChameleonForm()) { @f.FieldElementFor(m => m.PositionTitle) }
| Improve this Doc View SourceFieldFor<TModel, T>(Field<TModel>, Expression<Func<TModel, T>>, IFieldConfiguration)
Creates a single form field as a child of another form field.
Declaration
public static IFieldConfiguration FieldFor<TModel, T>(this Field<TModel> field, Expression<Func<TModel, T>> property, IFieldConfiguration config = null)
Parameters
Type | Name | Description |
---|---|---|
Field<TModel> | field | The parent field the field is being created in |
System.Linq.Expressions.Expression<System.Func<TModel, T>> | property | A lamdba expression to identify the field to render the field for |
IFieldConfiguration | config | Optional base field configuration |
Returns
Type | Description |
---|---|
IFieldConfiguration | A field configuration object that allows you to configure the field |
Type Parameters
Name | Description |
---|---|
TModel | The view model type for the current view |
T | The type of the field being generated |
Examples
@using (var f = s.BeginFieldFor(m => m.Company)) { @f.FieldFor(m => m.PositionTitle) }
| Improve this Doc View SourceFieldFor<TModel, T>(ISection<TModel>, Expression<Func<TModel, T>>, IFieldConfiguration)
Creates a single form field as a child of a form section.
Declaration
public static IFieldConfiguration FieldFor<TModel, T>(this ISection<TModel> section, Expression<Func<TModel, T>> property, IFieldConfiguration config = null)
Parameters
Type | Name | Description |
---|---|---|
ISection<TModel> | section | The section the field is being created in |
System.Linq.Expressions.Expression<System.Func<TModel, T>> | property | A lamdba expression to identify the field to render the field for |
IFieldConfiguration | config | Optional base field configuration |
Returns
Type | Description |
---|---|
IFieldConfiguration | A field configuration object that allows you to configure the field |
Type Parameters
Name | Description |
---|---|
TModel | The view model type for the current view |
T | The type of the field being generated |
Examples
@s.FieldFor(m => m.FirstName)
| Improve this Doc View SourceLabelFor<TModel, T>(IForm<TModel>, Expression<Func<TModel, T>>, IFieldConfiguration)
Creates a standalone label to be output in a form for a field.
Declaration
public static IFieldConfiguration LabelFor<TModel, T>(this IForm<TModel> form, Expression<Func<TModel, T>> property, IFieldConfiguration config = null)
Parameters
Type | Name | Description |
---|---|---|
IForm<TModel> | form | The form the label is being created in |
System.Linq.Expressions.Expression<System.Func<TModel, T>> | property | A lamdba expression to identify the field to render the label for |
IFieldConfiguration | config | Optional base field configuration |
Returns
Type | Description |
---|---|
IFieldConfiguration | The HTML for the label |
Type Parameters
Name | Description |
---|---|
TModel | The view model type for the current view |
T | The type of the field being generated |
Examples
@using (var f = Html.BeginChameleonForm()) { @f.LabelFor(m => m.PositionTitle) }
| Improve this Doc View SourceValidationMessageFor<TModel, T>(IForm<TModel>, Expression<Func<TModel, T>>, IFieldConfiguration)
Creates a standalone validation message to be output in a form for a field.
Declaration
public static IFieldConfiguration ValidationMessageFor<TModel, T>(this IForm<TModel> form, Expression<Func<TModel, T>> property, IFieldConfiguration config = null)
Parameters
Type | Name | Description |
---|---|---|
IForm<TModel> | form | The form the label is being created in |
System.Linq.Expressions.Expression<System.Func<TModel, T>> | property | A lamdba expression to identify the field to render the validation message for |
IFieldConfiguration | config | Optional base field configuration |
Returns
Type | Description |
---|---|
IFieldConfiguration | The HTML for the validation message |
Type Parameters
Name | Description |
---|---|
TModel | The view model type for the current view |
T | The type of the field being generated |
Examples
@using (var f = Html.BeginChameleonForm()) { @f.ValidationMessageFor(m => m.PositionTitle) }