Show / Hide Table of Contents

    Class FieldExtensions

    Extension methods for the creation of form fields, labels and validation messages.

    Inheritance
    System.Object
    FieldExtensions
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: ChameleonForms.Component
    Assembly: ChameleonForms.dll
    Syntax
    public static class FieldExtensions

    Methods

    | Improve this Doc View Source

    BeginFieldFor<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 Source

    FieldElementFor<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 Source

    FieldFor<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 Source

    FieldFor<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 Source

    LabelFor<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 Source

    ValidationMessageFor<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) }

    • Improve this Doc
    • View Source
    Back to top © Copyright 2012-2020 MRCollective, Rob Moore, Matt Davies and the contributors to ChameleonForms.