Interface IFieldConfiguration
Holds configuration data for a form field.
Inherited Members
Namespace: ChameleonForms.Component.Config
Assembly: ChameleonForms.Core.dll
Syntax
public interface IFieldConfiguration : IHtmlContent, IReadonlyFieldConfiguration
Properties
| Improve this Doc View SourceAttributes
Attributes to add to the form element's HTML.
Declaration
HtmlAttributes Attributes { get; }
Property Value
| Type | Description |
|---|---|
| HtmlAttributes |
Methods
| Improve this Doc View SourceAddClass(String)
Adds a CSS class (or a number of CSS classes) to the attributes.
Declaration
IFieldConfiguration AddClass(string class)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | class | The CSS class(es) to add |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
AddFieldContainerClass(String)
Specify one or more CSS classes to use for the field container element.
Declaration
IFieldConfiguration AddFieldContainerClass(string class)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | class | Any CSS class(es) to use for the field container element |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
AddLabelClass(String)
Specify one or more CSS classes to use for the field label.
Declaration
IFieldConfiguration AddLabelClass(string class)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | class | Any CSS class(es) to use for the field label |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
AddValidationClass(String)
Specify one or more CSS classes to use for the field validation message.
Declaration
IFieldConfiguration AddValidationClass(string class)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | class | Any CSS class(es) to use for the field validation message |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Append(IHtmlContent)
Appends the given HTML to the form field.
Declaration
IFieldConfiguration Append(IHtmlContent html)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.AspNetCore.Html.IHtmlContent | html | The HTML to append |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Append(Func<Object, IHtmlContent>)
Appends the given HTML to the form field.
Declaration
IFieldConfiguration Append(Func<dynamic, IHtmlContent> html)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<System.Object, Microsoft.AspNetCore.Html.IHtmlContent> | html | The HTML to append as a templated razor delegate |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Append(String)
Appends the given string to the form field.
Declaration
IFieldConfiguration Append(string str)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | str | The string to prepend |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
AsCheckboxList()
Renders the field as a list of radio options for selecting single values or checkbox items for selecting multiple values. Use for a list or boolean value.
Declaration
IFieldConfiguration AsCheckboxList()
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
See Also
| Improve this Doc View SourceAsDropDown()
Renders the field as a drop-down control. Use for a list or boolean value.
Declaration
IFieldConfiguration AsDropDown()
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
AsRadioList()
Renders the field as a list of radio options for selecting single values or checkbox items for selecting multiple values. Use for a list or boolean value.
Declaration
IFieldConfiguration AsRadioList()
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
See Also
| Improve this Doc View SourceAttr(Func<Object, Object>)
Adds or updates a HTML attribute with using a lambda method to express the attribute.
Declaration
IFieldConfiguration Attr(Func<object, object> attribute)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<System.Object, System.Object> | attribute | A lambda expression representing the attribute to set and its value |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Examples
h.Attr(style => "width: 100%;")
| Improve this Doc View SourceAttr(String, Object)
Adds or updates a HTML attribute with a given value.
Declaration
IFieldConfiguration Attr(string key, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | key | The name of the HTML attribute to add/update |
| System.Object | value | The value of the HTML attribute to add/update |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Attrs(IDictionary<String, Object>)
Adds or updates a set of HTML attributes using a dictionary to express the attributes.
Declaration
IFieldConfiguration Attrs(IDictionary<string, object> attributes)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<System.String, System.Object> | attributes | A dictionary of attributes |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Attrs(IDictionary<String, String>)
Adds or updates a set of HTML attributes using a dictionary to express the attributes.
Declaration
IFieldConfiguration Attrs(IDictionary<string, string> attributes)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<System.String, System.String> | attributes | A dictionary of attributes |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Attrs(Func<Object, Object>[])
Adds or updates a set of HTML attributes using lambda methods to express the attributes.
Declaration
IFieldConfiguration Attrs(params Func<object, object>[] attributes)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<System.Object, System.Object>[] | attributes | A list of lambas where the lambda variable name is the name of the attribute and the value is the value |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Attrs(Object)
Adds or updates a set of HTML attributes using anonymous objects to express the attributes.
Declaration
IFieldConfiguration Attrs(object attributes)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | attributes | An anonymous object of attributes |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Cols(Int32)
Sets the number of cols for a textarea to use.
Declaration
IFieldConfiguration Cols(int numCols)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | numCols | The number of cols for the textarea |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Disabled(Boolean)
Sets the field to be disabled (value not submitted, can not click).
Declaration
IFieldConfiguration Disabled(bool disabled = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | disabled |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Exclude(Enum[])
Excludes one or more Enum values from the generated field.
Declaration
IFieldConfiguration Exclude(params Enum[] enumValues)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Enum[] | enumValues | The value of Enum(s) to exclude from the generated field. |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration |
HideEmptyItem()
Hide the empty item that would normally display for the field.
Declaration
IFieldConfiguration HideEmptyItem()
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Id(String)
Override the default id for the field.
Declaration
IFieldConfiguration Id(string id)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | id | The text to use for the id |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
InlineLabel(IHtmlContent)
Sets an inline label for a checkbox.
Declaration
IFieldConfiguration InlineLabel(IHtmlContent labelHtml)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.AspNetCore.Html.IHtmlContent | labelHtml | The html to use for the label |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
InlineLabel(Func<Object, IHtmlContent>)
Sets an inline label for a checkbox.
Declaration
IFieldConfiguration InlineLabel(Func<dynamic, IHtmlContent> labelHtml)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<System.Object, Microsoft.AspNetCore.Html.IHtmlContent> | labelHtml | The html to use for the label as a templated razor delegate |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
InlineLabel(String)
Sets an inline label for a checkbox.
Declaration
IFieldConfiguration InlineLabel(string labelText)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | labelText | The text to use for the label |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
InlineLabelWrapsElement(Boolean)
Specify that inline labels should wrap their input element. Important for bootstrap.
Declaration
IFieldConfiguration InlineLabelWrapsElement(bool wrapElement = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | wrapElement | True if the input element should be wrapped. |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Label(IHtmlContent)
Override the default label for the field.
Declaration
IFieldConfiguration Label(IHtmlContent labelHtml)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.AspNetCore.Html.IHtmlContent | labelHtml | The text to use for the label |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Label(Func<Object, IHtmlContent>)
Override the default label for the field.
Declaration
IFieldConfiguration Label(Func<dynamic, IHtmlContent> labelHtml)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<System.Object, Microsoft.AspNetCore.Html.IHtmlContent> | labelHtml | The text to use for the label as a templated razor delegate |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Label(String)
Override the default label for the field.
Declaration
IFieldConfiguration Label(string labelText)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | labelText | The text to use for the label |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Max(Decimal)
Sets the maximum value to accept for numeric text controls.
Declaration
IFieldConfiguration Max(decimal max)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Decimal | max | The maximum value to accept |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Max(Int64)
Sets the maximum value to accept for numeric text controls.
Declaration
IFieldConfiguration Max(long max)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int64 | max | The maximum value to accept |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Max(String)
Sets the maximum value to accept for numeric text controls.
Declaration
IFieldConfiguration Max(string max)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | max | The maximum value to accept |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Min(Decimal)
Sets the minimum value to accept for numeric text controls.
Declaration
IFieldConfiguration Min(decimal min)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Decimal | min | The minimum value to accept |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Min(Int64)
Sets the minimum value to accept for numeric text controls.
Declaration
IFieldConfiguration Min(long min)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int64 | min | The minimum value to accept |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Min(String)
Sets the minimum value to accept for numeric text controls.
Declaration
IFieldConfiguration Min(string min)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | min | The minimum value to accept |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
OverrideFieldHtml(IHtmlContent)
Override the HTML of the form field.
This gives you ultimate flexibility with your field HTML when it's not quite what you want, but you still want the form template (e.g. label, surrounding html and validation message).
Declaration
IFieldConfiguration OverrideFieldHtml(IHtmlContent html)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.AspNetCore.Html.IHtmlContent | html | The HTML for the field |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
OverrideFieldHtml(Func<Object, IHtmlContent>)
Override the HTML of the form field.
This gives you ultimate flexibility with your field HTML when it's not quite what you want, but you still want the form template (e.g. label, surrounding html and validation message).
Declaration
IFieldConfiguration OverrideFieldHtml(Func<dynamic, IHtmlContent> html)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<System.Object, Microsoft.AspNetCore.Html.IHtmlContent> | html | The HTML for the field as a templated razor delegate |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Placeholder(String)
Sets a hint to the user of what can be entered in the field.
Declaration
IFieldConfiguration Placeholder(string placeholderText)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | placeholderText | The text to use for the placeholder |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Prepend(IHtmlContent)
Prepends the given HTML to the form field.
Declaration
IFieldConfiguration Prepend(IHtmlContent html)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.AspNetCore.Html.IHtmlContent | html | The HTML to prepend |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Prepend(Func<Object, IHtmlContent>)
Prepends the given HTML to the form field.
Declaration
IFieldConfiguration Prepend(Func<dynamic, IHtmlContent> html)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<System.Object, Microsoft.AspNetCore.Html.IHtmlContent> | html | The HTML to prepend as a templated razor delegate |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Prepend(String)
Prepends the given string to the form field.
Declaration
IFieldConfiguration Prepend(string str)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | str | The string to prepend |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Readonly(Boolean)
Sets the field to be readonly (value can not be modified).
Declaration
IFieldConfiguration Readonly(bool readonly = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | readonly |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Required(Boolean)
Sets the field to be required.
Declaration
IFieldConfiguration Required(bool required = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | required |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Rows(Int32)
Sets the number of rows for a textarea to use.
Declaration
IFieldConfiguration Rows(int numRows)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | numRows | The number of rows for the textarea |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
SetField(IHtmlContent)
Sets the field that the field configuration is wrapping so that a call to ToHtmlString() will output the given field.
Declaration
void SetField(IHtmlContent field)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.AspNetCore.Html.IHtmlContent | field | The field being configured |
SetField(Func<IHtmlContent>)
Sets a lambda expression to get the field that the field configuration is wrapping so that a call to ToHtmlString() will output the given field.
Declaration
void SetField(Func<IHtmlContent> field)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<Microsoft.AspNetCore.Html.IHtmlContent> | field | A lambda returning the HTML to output |
SetField(Func<Object, IHtmlContent>)
Sets the field that the field configuration is wrapping so that a call to ToHtmlString() will output the given field.
Declaration
void SetField(Func<dynamic, IHtmlContent> field)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<System.Object, Microsoft.AspNetCore.Html.IHtmlContent> | field | The field being configured as a templated razor delegate |
Step(Decimal)
Sets the stepping interval to use for numeric text controls.
Declaration
IFieldConfiguration Step(decimal step)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Decimal | step | The stepping interval |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
Step(Int64)
Sets the stepping interval to use for numeric text controls.
Declaration
IFieldConfiguration Step(long step)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int64 | step | The stepping interval |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
WithFalseAs(String)
Change the label that represents false.
Declaration
IFieldConfiguration WithFalseAs(string falseString)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | falseString | The label to use as false |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
WithFormatString(String)
Uses the given format string when outputting the field value.
Declaration
IFieldConfiguration WithFormatString(string formatString)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | formatString | The format string to use |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
WithHint(IHtmlContent)
Supply a HTML hint to display along with the field.
Declaration
IFieldConfiguration WithHint(IHtmlContent hint)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.AspNetCore.Html.IHtmlContent | hint | The hint markup |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
WithHint(Func<Object, IHtmlContent>)
Supply a HTML hint to display along with the field.
Declaration
IFieldConfiguration WithHint(Func<dynamic, IHtmlContent> hint)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<System.Object, Microsoft.AspNetCore.Html.IHtmlContent> | hint | The hint markup as a templated razor delegate |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
WithHint(String)
Supply a string hint to display along with the field.
Declaration
IFieldConfiguration WithHint(string hint)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | hint | The hint string |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
WithHintId(String)
Specify an ID to use for a field hint.
Declaration
IFieldConfiguration WithHintId(string hintId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | hintId | The ID to use |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
WithNoneAs(String)
Change the label that represents none.
Declaration
IFieldConfiguration WithNoneAs(string noneString)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | noneString | The label to use as none |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
WithoutInlineLabel()
Specify that no inline label should be generated.
Declaration
IFieldConfiguration WithoutInlineLabel()
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
WithoutLabelElement()
Don't use a <label>, but still include the label text for the field.
Declaration
IFieldConfiguration WithoutLabelElement()
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |
WithTrueAs(String)
Change the label that represents true.
Declaration
IFieldConfiguration WithTrueAs(string trueString)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | trueString | The label to use as true |
Returns
| Type | Description |
|---|---|
| IFieldConfiguration | The IFieldConfiguration to allow for method chaining |