C# Class Castle.MonoRail.Framework.Helpers.FormHelper

The FormHelper allows you to output html input elements using the conventions necessary to use the DataBinder on the server side. Ultimately it allows you do to a bi-directional binding -- if used properly.
Elements generation

Buttons Submit(string)
Button(string)
ButtonElement(string)
Select Select(string,IEnumerable) Text area TextArea(string) Hidden field HiddenField(string) Checkbox field CheckboxField(string)
CreateCheckboxList(string,IEnumerable)
Radio field RadioField(string,object) File upload FileField(string) Text field TextField(string)
TextFieldValue(string, object)
NumberField(string)
NumberFieldValue(string, object)
Password field PasswordField(string)
PasswordNumberField(string)
Labels LabelFor(string,string)
LabelFor(string,string,IDictionary)

FormValidation
The following operations are related to the Form Validation support:

FormTag(IDictionary) and EndFormTag Opens/close the form tag. They are required to use the form validation DisableValidation Disables validation altogether UseWebValidatorProvider Sets a custom Browser validator provider UsePrototypeValidation Configures the helper to use the prototype easy field validation. Must be invoked before FormTag UsefValidate Configures the helper to use the fValidate. Deprecated. UseZebdaValidation Configures the helper to use the Zebda. Must be invoked before FormTag

Mask support.
For most elements, you can use the entries mask and optionally mask_separator to define a mask for your inputs. Kudos to mordechai Sandhaus - 52action.com

For example: mask='2,5',mask_separator='/' will mask the content to '12/34/1234'

Inheritance: AbstractHelper, IServiceEnabledComponent
Show file Open project: nats/castle-1.0.3-mono Class Usage Examples

Protected Properties

Property Type Description
FieldFlags BindingFlags
PropertyFlags BindingFlags
PropertyFlags2 BindingFlags
logger ILogger

Private Properties

Property Type Description
AddChecked void
ApplyFilterOptions void
ApplyNumberOnlyOptions void
AreEqual bool
AssertIsValidArray void
CheckForExistenceAndExtractIndex bool
CheckboxItem string
CollectValidators IValidator[]
CreateHtmlId string
GetArrayElement object
ObtainRootType System.Type
QueryPropertyInfoRecursive System.Reflection.PropertyInfo
RemoveChecked void
ResolveFlagsToUse BindingFlags
SafeHtmlEncode string

Public Methods

Method Description
AjaxFormTag ( IDictionary parameters ) : string

Generate Ajax form tag for ajax based form submission. Experimental.

Button ( string value ) : string

Generates an input button element.

Button ( string value, IDictionary attributes ) : string

Generates an input button element.

ButtonElement ( string innerText ) : string

Creates a basic button element of type submit.

ButtonElement ( string innerText, string type ) : string

Creates a basic button element of the specified type.

ButtonElement ( string innerText, string type, IDictionary attributes ) : string

Creates a basic button element of the specified type and with specified attributes.

CheckboxField ( string target ) : string

Generates a checkbox field. In fact it generates two as a way to send a value if the primary checkbox is not checked. This allow the process the be aware of the unchecked value and act accordingly.

CheckboxField ( string target, IDictionary attributes ) : string

Generates a checkbox field. In fact it generates two as a way to send a value if the primary checkbox is not checked. This allow the process the be aware of the unchecked value and act accordingly.

The checked and unchecked values sent to the server defaults to true and false. You can override them using the parameters trueValue and falseValue, but the DataBinder is prepared only to treat boolean arrays.

CreateCheckboxList ( string target, IEnumerable dataSource ) : CheckboxList

Creates a CheckboxList instance which is enumerable. For each interaction you can invoke CheckboxList.Item() which will correctly render a checkbox input element for the current element on the supplied set (dataSource).

The enumerable item will be an element of the dataSource.

If the dataSource elements are complex objects (ie not string or primitives), supply the parameters value and text to the dictionary to make the helper use the specified properties to extract the option value and content respectively.

Usually both the target and obviously the dataSource are sets with multiple items. The element types tend to be the same. If they are not, you might have to specify the suffix parameters on the attributes as it would not be inferred.

CreateCheckboxList ( string target, IEnumerable dataSource, IDictionary attributes ) : CheckboxList

Creates a CheckboxList instance which is enumerable. For each interaction you can invoke CheckboxList.Item() which will correctly render a checkbox input element for the current element on the supplied set (dataSource).

The enumerable item will be an element of the dataSource.

If the dataSource elements are complex objects (ie not string or primitives), supply the parameters value and text to the dictionary to make the helper use the specified properties to extract the option value and content respectively.

Usually both the target and obviously the dataSource are sets with multiple items. The element types tend to be the same. If they are not, you might have to specify the suffix parameters on the attributes as it would not be inferred.

DisableValidation ( ) : void

Disables the validation.

EndFormTag ( ) : string

Renders an end form element.

Should be used if you are using form validation. Some validation approaches uses the end form before or after appending a javascript snippet.

EnumToPairs ( Type enumType ) : string>[].Pair

Creates a list of pairs for the enum type.

FileField ( string target ) : string

Generates an input file element.

Dirrently than other operations exposed by this helper, no value is extracted for this operation

FileField ( string target, IDictionary attributes ) : string

Generates an input file element.

Dirrently than other operations exposed by this helper, no value is extracted for this operation

FilteredTextField ( string target, IDictionary attributes ) : string

Generates an input text element with a javascript that prevents the chars listed in the forbid attribute from being entered.

You must invoke FormHelper.InstallScripts before using it.

FormTag ( IDictionary parameters ) : string

Creates a form tag based on the parameters.

Javascript validation can also be bound to the form and|or elements nested as long as the helper is able to reach the Type of the object used on your view code

The action attribute generation will use UrlHelper

The parameters are used to build a url and also to form the tag. For notes on the url see DefaultUrlBuilder.BuildUrl(UrlInfo,IDictionary). The other parameters supported follows noaction boolean. Disables the generation of an action method string. The http method to use. Defaults to post id string. The form id. More parameters can be accepted depending on the form validation strategy you are using (if any).

FormTag ( string url, IDictionary parameters ) : string

Creates a form tag based on the parameters.

Javascript validation can also be bound to the form and|or elements nested as long as the helper is able to reach the Type of the object used on your view code

The action attribute generation will use UrlHelper

The following parameters are accepted. method string. The http method to use. Defaults to post id string. The form id. More parameters can be accepted depending on the form validation strategy you are using (if any).

HiddenField ( string target ) : string

Generates a hidden form element.

The value is extracted from the target (if available)

HiddenField ( string target, IDictionary attributes ) : string

Generates a hidden form element.

The value is extracted from the target (if available)

HiddenField ( string target, object value ) : string

Generates a hidden form element with the specified value

HiddenField ( string target, object value, IDictionary attributes ) : string

Generates a hidden form element with the specified value

InstallScripts ( ) : string

Renders a Javascript library inside a single script tag.

LabelFor ( string target, string label ) : string

Generates a label element.

LabelFor ( string target, string label, IDictionary attributes ) : string

Generates a label element.

NumberField ( string target ) : string

Generates an input text element with a javascript that prevents chars other than numbers from being entered.

The value is extracted from the target (if available)

You must include the formhelper javascript functions to use the NumberField. See InstallScripts

NumberField ( string target, IDictionary attributes ) : string

Generates an input text element with a javascript that prevents chars other than numbers from being entered.

The value is extracted from the target (if available)

You must include the formhelper javascript functions to use the NumberField. See InstallScripts

You can optionally pass an exceptions value through the dictionary. It must be a comma separated list of chars that can be accepted on the field. For example:

FormHelper.NumberField("product.price", {exceptions='13,10,11'}) In this case the key codes 13, 10 and 11 will be accepted on the field.

You can aslo optionally pass an forbid value through the dictionary. It must be a comma separated list of chars that cannot be accepted on the field. For example:

FormHelper.NumberField("product.price", {forbid='46'}) In this case the key code 46 (period) will not be accepted on the field.
NumberFieldValue ( string target, object value ) : string

Generates an input text element with a javascript that prevents chars other than numbers from being entered. The value is not gathered from the context, instead you specify it on the second argument

You must include the formhelper javascript functions to use the NumberField. See InstallScripts

NumberFieldValue ( string target, object value, IDictionary attributes ) : string

Generates an input text element with a javascript that prevents chars other than numbers from being entered. The value is not gathered from the context, instead you specify it on the second argument

You must include the formhelper javascript functions to use the NumberField. See InstallScripts

PasswordField ( string target ) : string

Generates a password input field.

PasswordField ( string target, IDictionary attributes ) : string

Generates a password input field.

PasswordNumberField ( string target ) : string

Generates an input password element with a javascript that prevents chars other than numbers from being entered.

The value is extracted from the target (if available)

You must invoke FormHelper.InstallScripts before using it

PasswordNumberField ( string target, IDictionary attributes ) : string

Generates an input password element with a javascript that prevents chars other than numbers from being entered.

The value is extracted from the target (if available)

You can optionally pass an exceptions value through the dictionary. It must be a comma separated list of chars that can be accepted on the field. For example:

FormHelper.NumberField("product.price", {exceptions='13,10,11'}) In this case the key codes 13, 10 and 11 will be accepted on the field.

You can aslo optionally pass an forbid value through the dictionary. It must be a comma separated list of chars that cannot be accepted on the field. For example:

FormHelper.NumberField("product.price", {forbid='46'}) In this case the key code 46 (period) will not be accepted on the field.

You must invoke FormHelper.InstallScripts before using it

Pop ( ) : void

Pops this instance. Experimental.

Push ( string target ) : void

Pushes the specified target. Experimental.

Push ( string target, IDictionary parameters ) : void

Pushes the specified target. Experimental.

RadioField ( string target, object valueToSend ) : string

Generates a radio input type with the specified value to send to the served in case the element in checked. It will automatically check the radio if the target evaluated value is equal to the specified valueToSend.

RadioField ( string target, object valueToSend, IDictionary attributes ) : string

Generates a radio input type with the specified value to send to the served in case the element in checked. It will automatically check the radio if the target evaluated value is equal to the specified valueToSend.

Select ( string target, IEnumerable dataSource ) : string

Creates a select element and its options based on the dataSource. If the dataSource elements are complex objects (ie not string or primitives), supply the parameters value and text to the dictionary to make the helper use the specified properties to extract the option value and content respectively.

You can also specify the attribute firstoption to force the first option be something like 'please select'. You can set the value of firstoption by specifying the attribute firstoptionvalue. The default value is '0'.

Usually the target is a single value and the dataSource is obviously a set with multiple items. The element types tend to be the same. If they are not, you might have to specify the suffix parameters on the attributes as it would not be inferred.

The target can also be a set. In this case the intersection will be the initially selected elements.

Select ( string target, IEnumerable dataSource, IDictionary attributes ) : string

Creates a select element and its options based on the dataSource. If the dataSource elements are complex objects (ie not string or primitives), supply the parameters value and text to the dictionary to make the helper use the specified properties to extract the option value and content respectively.

You can also specify the attribute firstoption to force the first option be something like 'please select'. You can set the value of firstoption by specifying the attribute firstoptionvalue. The default value is '0'.

Usually the target is a single value and the dataSource is obviously a set with multiple items. The element types tend to be the same. If they are not, you might have to specify the suffix parameters on the attributes as it would not be inferred.

The target can also be a set. In this case the intersection will be the initially selected elements.

Select ( string target, object selectedValue, IEnumerable dataSource, IDictionary attributes ) : string

Creates a select element and its options based on the dataSource. If the dataSource elements are complex objects (ie not string or primitives), supply the parameters value and text to the dictionary to make the helper use the specified properties to extract the option value and content respectively.

You can also specify the attribute firstoption to force the first option be something like 'please select'. You can set the value of firstoption by specifying the attribute firstoptionvalue. The default value is '0'.

Usually the target is a single value and the dataSource is obviously a set with multiple items. The element types tend to be the same. If they are not, you might have to specify the suffix parameters on the attributes as it would not be inferred.

The target can also be a set. In this case the intersection will be the initially selected elements.

Service ( IServiceProvider provider ) : void

Invoked by the framework in order to give a chance to obtain other services

Submit ( string value ) : string

Generates an input submit element.

Submit ( string value, IDictionary attributes ) : string

Generates an input submit element.

TextArea ( string target ) : string

Generates a textarea element.

The value is extracted from the target (if available)

TextArea ( string target, IDictionary attributes ) : string

Generates a textarea element.

The value is extracted from the target (if available)

TextAreaValue ( string target, object value, IDictionary attributes ) : string

Generates a textarea element with a specified value.

TextField ( string target ) : string

Generates an input text element.

The value is extracted from the target (if available)

TextField ( string target, IDictionary attributes ) : string

Generates an input text element.

The value is extracted from the target (if available)

TextFieldValue ( string target, object value ) : string

Generates an input text form element with the supplied value

TextFieldValue ( string target, object value, IDictionary attributes ) : string

Generates an input text form element with the supplied value

UsePrototypeValidation ( ) : void

Configures this FormHelper instance to use Prototype for form fields validation

UseWebValidatorProvider ( IBrowserValidatorProvider provider ) : void

Configures this FormHelper instance to use the supplied web validator to generate field validation.

UseZebdaValidation ( ) : void

Configures this FormHelper instance to use Zebda for form fields validation

UsefValidate ( ) : void

Configures this FormHelper instance to use fValidate for form fields validation

Protected Methods

Method Description
ApplyValidation ( InputElementType inputType, string target, IDictionary &attributes ) : void

Applies the validation.

CreateHtmlId ( IDictionary attributes, string target ) : string

Creates the HTML id.

CreateHtmlId ( IDictionary attributes, string target, bool removeEntry ) : string

Creates the HTML id.

CreateInputElement ( string type, string value, IDictionary attributes ) : string

Creates the input element.

CreateInputElement ( string type, string target, Object value, IDictionary attributes ) : string

Creates the specified input element using the specified parameters to supply the name, value, id and others html attributes.

CreateInputElement ( string type, string id, string target, string value, IDictionary attributes ) : string

Creates the specified input element using the specified parameters to supply the name, value, id and others html attributes.

FormatIfNecessary ( object value, IDictionary attributes ) : string

Formats if necessary.

GenerateSelect ( string target, object selectedValue, IEnumerable dataSource, IDictionary attributes ) : string

Generates the select.

IsPresent ( object value, object initialSetValue, ValueGetter propertyOnInitialSet, bool isMultiple ) : bool

Determines whether the present value matches the value on the initialSetValue (which can be a single value or a set)

ObtainRootInstance ( RequestContext context, string target ) : object

Obtains the root instance.

ObtainRootInstance ( RequestContext context, string target, string &pieces ) : object

Obtains the root instance.

ObtainTargetProperty ( RequestContext context, string target, Action action ) : PropertyInfo

Obtains the target property.

ObtainValue ( RequestContext context, string target ) : object

Queries the context for the target value

ObtainValue ( string target ) : object

Queries the context for the target value

QueryPropertyRecursive ( object rootInstance, string propertyPath, int piece ) : object

RewriteTargetIfWithinObjectScope ( string target ) : string

Rewrites the target if within object scope.

Private Methods

Method Description
AddChecked ( IDictionary attributes ) : void
ApplyFilterOptions ( IDictionary attributes ) : void
ApplyNumberOnlyOptions ( IDictionary attributes ) : void
AreEqual ( object left, object right ) : bool
AssertIsValidArray ( object instance, string property, int index ) : void
CheckForExistenceAndExtractIndex ( string &property, int &index ) : bool
CheckboxItem ( int index, string target, string suffix, Castle.MonoRail.Framework.Helpers.SetItem item, IDictionary attributes ) : string

Outputs a checkbox element (for internal use)

CollectValidators ( RequestContext requestContext, string target ) : IValidator[]
CreateHtmlId ( string name ) : string
GetArrayElement ( object instance, int index ) : object
ObtainRootType ( RequestContext context, string target, string &pieces ) : Type

Obtains the type of the root.

QueryPropertyInfoRecursive ( Type type, string propertyPath, int piece, Action action ) : PropertyInfo
RemoveChecked ( IDictionary attributes ) : void
ResolveFlagsToUse ( Type type ) : BindingFlags
SafeHtmlEncode ( string content ) : string

Method Details

AjaxFormTag() public method

Generate Ajax form tag for ajax based form submission. Experimental.
public AjaxFormTag ( IDictionary parameters ) : string
parameters IDictionary
return string

ApplyValidation() protected method

Applies the validation.
protected ApplyValidation ( InputElementType inputType, string target, IDictionary &attributes ) : void
inputType InputElementType Type of the input.
target string The target.
attributes IDictionary The attributes.
return void

Button() public method

Generates an input button element.
public Button ( string value ) : string
value string The value.
return string

Button() public method

Generates an input button element.
public Button ( string value, IDictionary attributes ) : string
value string The value.
attributes IDictionary Attributes for the FormHelper method and for the html element it generates
return string

ButtonElement() public method

Creates a basic button element of type submit.
public ButtonElement ( string innerText ) : string
innerText string The inner text of the button element.
return string

ButtonElement() public method

Creates a basic button element of the specified type.
public ButtonElement ( string innerText, string type ) : string
innerText string The inner text of the button element.
type string The type of the button.
return string

ButtonElement() public method

Creates a basic button element of the specified type and with specified attributes.
public ButtonElement ( string innerText, string type, IDictionary attributes ) : string
innerText string The inner text of the button element.
type string The type of the button.
attributes IDictionary Attributes for the FormHelper method and for the html element it generates
return string

CheckboxField() public method

Generates a checkbox field. In fact it generates two as a way to send a value if the primary checkbox is not checked. This allow the process the be aware of the unchecked value and act accordingly.
public CheckboxField ( string target ) : string
target string The object to get the value from and to be based on to create the element name.
return string

CheckboxField() public method

Generates a checkbox field. In fact it generates two as a way to send a value if the primary checkbox is not checked. This allow the process the be aware of the unchecked value and act accordingly.

The checked and unchecked values sent to the server defaults to true and false. You can override them using the parameters trueValue and falseValue, but the DataBinder is prepared only to treat boolean arrays.

public CheckboxField ( string target, IDictionary attributes ) : string
target string The object to get the value from and to be based on to create the element name.
attributes IDictionary Attributes for the FormHelper method and for the html element it generates
return string

CreateCheckboxList() public method

Creates a CheckboxList instance which is enumerable. For each interaction you can invoke CheckboxList.Item() which will correctly render a checkbox input element for the current element on the supplied set (dataSource).

The enumerable item will be an element of the dataSource.

If the dataSource elements are complex objects (ie not string or primitives), supply the parameters value and text to the dictionary to make the helper use the specified properties to extract the option value and content respectively.

Usually both the target and obviously the dataSource are sets with multiple items. The element types tend to be the same. If they are not, you might have to specify the suffix parameters on the attributes as it would not be inferred.

public CreateCheckboxList ( string target, IEnumerable dataSource ) : CheckboxList
target string The object to get the value from and to be based on to create the element name.
dataSource IEnumerable The set of available elements
return CheckboxList

CreateCheckboxList() public method

Creates a CheckboxList instance which is enumerable. For each interaction you can invoke CheckboxList.Item() which will correctly render a checkbox input element for the current element on the supplied set (dataSource).

The enumerable item will be an element of the dataSource.

If the dataSource elements are complex objects (ie not string or primitives), supply the parameters value and text to the dictionary to make the helper use the specified properties to extract the option value and content respectively.

Usually both the target and obviously the dataSource are sets with multiple items. The element types tend to be the same. If they are not, you might have to specify the suffix parameters on the attributes as it would not be inferred.

public CreateCheckboxList ( string target, IEnumerable dataSource, IDictionary attributes ) : CheckboxList
target string The object to get the value from and to be based on to create the element name.
dataSource IEnumerable The set of available elements
attributes IDictionary Attributes for the FormHelper method and for the html element it generates
return CheckboxList

CreateHtmlId() protected static method

Creates the HTML id.
protected static CreateHtmlId ( IDictionary attributes, string target ) : string
attributes IDictionary The attributes.
target string The target.
return string

CreateHtmlId() protected static method

Creates the HTML id.
protected static CreateHtmlId ( IDictionary attributes, string target, bool removeEntry ) : string
attributes IDictionary The attributes.
target string The target.
removeEntry bool if set to true [remove entry].
return string

CreateInputElement() protected method

Creates the input element.
protected CreateInputElement ( string type, string value, IDictionary attributes ) : string
type string The type.
value string The value.
attributes IDictionary The attributes.
return string

CreateInputElement() protected method

Creates the specified input element using the specified parameters to supply the name, value, id and others html attributes.
protected CreateInputElement ( string type, string target, Object value, IDictionary attributes ) : string
type string
target string The object to get the value from and to be based on to create the element name.
value Object
attributes IDictionary Attributes for the FormHelper method and for the html element it generates
return string

CreateInputElement() protected method

Creates the specified input element using the specified parameters to supply the name, value, id and others html attributes.
protected CreateInputElement ( string type, string id, string target, string value, IDictionary attributes ) : string
type string
id string
target string The object to get the value from and to be based on to create the element name.
value string
attributes IDictionary Attributes for the FormHelper method and for the html element it generates
return string

DisableValidation() public method

Disables the validation.
public DisableValidation ( ) : void
return void

EndFormTag() public method

Renders an end form element.
Should be used if you are using form validation. Some validation approaches uses the end form before or after appending a javascript snippet.
public EndFormTag ( ) : string
return string

EnumToPairs() public static method

Creates a list of pairs for the enum type.
public static EnumToPairs ( Type enumType ) : string>[].Pair
enumType System.Type enum type.
return string>[].Pair

FileField() public method

Generates an input file element.

Dirrently than other operations exposed by this helper, no value is extracted for this operation

public FileField ( string target ) : string
target string The object to be based on when creating the element name.
return string

FileField() public method

Generates an input file element.

Dirrently than other operations exposed by this helper, no value is extracted for this operation

public FileField ( string target, IDictionary attributes ) : string
target string The object to be based on when creating the element name.
attributes IDictionary Attributes for the FormHelper method and for the html element it generates
return string

FilteredTextField() public method

Generates an input text element with a javascript that prevents the chars listed in the forbid attribute from being entered.
You must invoke FormHelper.InstallScripts before using it.
public FilteredTextField ( string target, IDictionary attributes ) : string
target string The object to get the value from and to be based on to create the element name.
attributes IDictionary Attributes for the FormHelper method and for the html element it generates
return string

FormTag() public method

Creates a form tag based on the parameters.

Javascript validation can also be bound to the form and|or elements nested as long as the helper is able to reach the Type of the object used on your view code

The action attribute generation will use UrlHelper

The parameters are used to build a url and also to form the tag. For notes on the url see DefaultUrlBuilder.BuildUrl(UrlInfo,IDictionary). The other parameters supported follows noaction boolean. Disables the generation of an action method string. The http method to use. Defaults to post id string. The form id. More parameters can be accepted depending on the form validation strategy you are using (if any).
public FormTag ( IDictionary parameters ) : string
parameters IDictionary The parameters for the tag or for action and form validation generation.
return string

FormTag() public method

Creates a form tag based on the parameters.

Javascript validation can also be bound to the form and|or elements nested as long as the helper is able to reach the Type of the object used on your view code

The action attribute generation will use UrlHelper

The following parameters are accepted. method string. The http method to use. Defaults to post id string. The form id. More parameters can be accepted depending on the form validation strategy you are using (if any).
public FormTag ( string url, IDictionary parameters ) : string
url string The hardcoded url.
parameters IDictionary The parameters for the tag or for action and form validation generation.
return string

FormatIfNecessary() protected static method

Formats if necessary.
protected static FormatIfNecessary ( object value, IDictionary attributes ) : string
value object The value.
attributes IDictionary The attributes.
return string

GenerateSelect() protected method

Generates the select.
protected GenerateSelect ( string target, object selectedValue, IEnumerable dataSource, IDictionary attributes ) : string
target string The target.
selectedValue object The selected value.
dataSource IEnumerable The data source.
attributes IDictionary The attributes.
return string

HiddenField() public method

Generates a hidden form element.

The value is extracted from the target (if available)

public HiddenField ( string target ) : string
target string The object to get the value from and to be based on to create the element name.
return string

HiddenField() public method

Generates a hidden form element.

The value is extracted from the target (if available)

public HiddenField ( string target, IDictionary attributes ) : string
target string The object to get the value from and to be based on to create the element name.
attributes IDictionary Attributes for the FormHelper method and for the html element it generates
return string

HiddenField() public method

Generates a hidden form element with the specified value
public HiddenField ( string target, object value ) : string
target string The object to get the value from and to be based on to create the element name.
value object The value for the hidden field
return string

HiddenField() public method

Generates a hidden form element with the specified value
public HiddenField ( string target, object value, IDictionary attributes ) : string
target string The object to get the value from and to be based on to create the element name.
value object The value for the hidden field
attributes IDictionary Attributes for the FormHelper method and for the html element it generates
return string

InstallScripts() public method

Renders a Javascript library inside a single script tag.
public InstallScripts ( ) : string
return string

IsPresent() protected static method

Determines whether the present value matches the value on the initialSetValue (which can be a single value or a set)
protected static IsPresent ( object value, object initialSetValue, ValueGetter propertyOnInitialSet, bool isMultiple ) : bool
value object Value from the datasource
initialSetValue object Value from the initial selection set
propertyOnInitialSet ValueGetter Optional. Property to obtain the value from
isMultiple bool true if the initial selection is a set
return bool

LabelFor() public method

Generates a label element.
public LabelFor ( string target, string label ) : string
target string The object to get the value from and to be based on to create the element name.
label string Legend
return string

LabelFor() public method

Generates a label element.
public LabelFor ( string target, string label, IDictionary attributes ) : string
target string The object to get the value from and to be based on to create the element name.
label string Legend
attributes IDictionary Attributes for the FormHelper method and for the html element it generates
return string

NumberField() public method

Generates an input text element with a javascript that prevents chars other than numbers from being entered.

The value is extracted from the target (if available)

You must include the formhelper javascript functions to use the NumberField. See InstallScripts
public NumberField ( string target ) : string
target string The object to get the value from and to be based on to create the element name.
return string

NumberField() public method

Generates an input text element with a javascript that prevents chars other than numbers from being entered.

The value is extracted from the target (if available)

You must include the formhelper javascript functions to use the NumberField. See InstallScripts

You can optionally pass an exceptions value through the dictionary. It must be a comma separated list of chars that can be accepted on the field. For example:

FormHelper.NumberField("product.price", {exceptions='13,10,11'}) In this case the key codes 13, 10 and 11 will be accepted on the field.

You can aslo optionally pass an forbid value through the dictionary. It must be a comma separated list of chars that cannot be accepted on the field. For example:

FormHelper.NumberField("product.price", {forbid='46'}) In this case the key code 46 (period) will not be accepted on the field.
public NumberField ( string target, IDictionary attributes ) : string
target string The object to get the value from and to be based on to create the element name.
attributes IDictionary Attributes for the FormHelper method and for the html element it generates
return string

NumberFieldValue() public method

Generates an input text element with a javascript that prevents chars other than numbers from being entered. The value is not gathered from the context, instead you specify it on the second argument
You must include the formhelper javascript functions to use the NumberField. See InstallScripts
public NumberFieldValue ( string target, object value ) : string
target string The object to get the value from and to be based on to create the element name.
value object The current value to output.
return string

NumberFieldValue() public method

Generates an input text element with a javascript that prevents chars other than numbers from being entered. The value is not gathered from the context, instead you specify it on the second argument
You must include the formhelper javascript functions to use the NumberField. See InstallScripts
public NumberFieldValue ( string target, object value, IDictionary attributes ) : string
target string The object to get the value from and to be based on to create the element name.
value object The current value to output.
attributes IDictionary Attributes for the FormHelper method and for the html element it generates
return string

ObtainRootInstance() protected method

Obtains the root instance.
protected ObtainRootInstance ( RequestContext context, string target ) : object
context RequestContext The context.
target string The object to get the value from and to be based on to create the element name.
return object

ObtainRootInstance() protected method

Obtains the root instance.
protected ObtainRootInstance ( RequestContext context, string target, string &pieces ) : object
context RequestContext The context.
target string The target.
pieces string The pieces.
return object

ObtainTargetProperty() protected method

Obtains the target property.
protected ObtainTargetProperty ( RequestContext context, string target, Action action ) : PropertyInfo
context RequestContext The context.
target string The target.
action Action The action.
return System.Reflection.PropertyInfo

ObtainValue() protected method

Queries the context for the target value
protected ObtainValue ( RequestContext context, string target ) : object
context RequestContext
target string The object to get the value from and to be based on to create the element name.
return object

ObtainValue() protected method

Queries the context for the target value
protected ObtainValue ( string target ) : object
target string The object to get the value from and to be based on to create the element name.
return object

PasswordField() public method

Generates a password input field.
public PasswordField ( string target ) : string
target string The object to get the value from and to be based on to create the element name.
return string

PasswordField() public method

Generates a password input field.
public PasswordField ( string target, IDictionary attributes ) : string
target string The object to get the value from and to be based on to create the element name.
attributes IDictionary Attributes for the FormHelper method and for the html element it generates
return string

PasswordNumberField() public method

Generates an input password element with a javascript that prevents chars other than numbers from being entered.

The value is extracted from the target (if available)

You must invoke FormHelper.InstallScripts before using it
public PasswordNumberField ( string target ) : string
target string The object to get the value from and to be based on to create the element name.
return string

PasswordNumberField() public method

Generates an input password element with a javascript that prevents chars other than numbers from being entered.

The value is extracted from the target (if available)

You can optionally pass an exceptions value through the dictionary. It must be a comma separated list of chars that can be accepted on the field. For example:

FormHelper.NumberField("product.price", {exceptions='13,10,11'}) In this case the key codes 13, 10 and 11 will be accepted on the field.

You can aslo optionally pass an forbid value through the dictionary. It must be a comma separated list of chars that cannot be accepted on the field. For example:

FormHelper.NumberField("product.price", {forbid='46'}) In this case the key code 46 (period) will not be accepted on the field.
You must invoke FormHelper.InstallScripts before using it
public PasswordNumberField ( string target, IDictionary attributes ) : string
target string The object to get the value from and to be based on to create the element name.
attributes IDictionary Attributes for the FormHelper method and for the html element it generates
return string

Pop() public method

Pops this instance. Experimental.
public Pop ( ) : void
return void

Push() public method

Pushes the specified target. Experimental.
public Push ( string target ) : void
target string The target.
return void

Push() public method

Pushes the specified target. Experimental.
public Push ( string target, IDictionary parameters ) : void
target string The target.
parameters IDictionary The parameters.
return void

QueryPropertyRecursive() protected method

protected QueryPropertyRecursive ( object rootInstance, string propertyPath, int piece ) : object
rootInstance object
propertyPath string
piece int
return object

RadioField() public method

Generates a radio input type with the specified value to send to the served in case the element in checked. It will automatically check the radio if the target evaluated value is equal to the specified valueToSend.
public RadioField ( string target, object valueToSend ) : string
target string The object to get the value from and to be based on to create the element name.
valueToSend object
return string

RadioField() public method

Generates a radio input type with the specified value to send to the served in case the element in checked. It will automatically check the radio if the target evaluated value is equal to the specified valueToSend.
public RadioField ( string target, object valueToSend, IDictionary attributes ) : string
target string The object to get the value from and to be based on to create the element name.
valueToSend object
attributes IDictionary Attributes for the FormHelper method and for the html element it generates
return string

RewriteTargetIfWithinObjectScope() protected method

Rewrites the target if within object scope.
protected RewriteTargetIfWithinObjectScope ( string target ) : string
target string The target.
return string

Select() public method

Creates a select element and its options based on the dataSource. If the dataSource elements are complex objects (ie not string or primitives), supply the parameters value and text to the dictionary to make the helper use the specified properties to extract the option value and content respectively.

You can also specify the attribute firstoption to force the first option be something like 'please select'. You can set the value of firstoption by specifying the attribute firstoptionvalue. The default value is '0'.

Usually the target is a single value and the dataSource is obviously a set with multiple items. The element types tend to be the same. If they are not, you might have to specify the suffix parameters on the attributes as it would not be inferred.

The target can also be a set. In this case the intersection will be the initially selected elements.

public Select ( string target, IEnumerable dataSource ) : string
target string The object to get the value from and to be based on to create the element name.
dataSource IEnumerable The set of available elements
return string

Select() public method

Creates a select element and its options based on the dataSource. If the dataSource elements are complex objects (ie not string or primitives), supply the parameters value and text to the dictionary to make the helper use the specified properties to extract the option value and content respectively.

You can also specify the attribute firstoption to force the first option be something like 'please select'. You can set the value of firstoption by specifying the attribute firstoptionvalue. The default value is '0'.

Usually the target is a single value and the dataSource is obviously a set with multiple items. The element types tend to be the same. If they are not, you might have to specify the suffix parameters on the attributes as it would not be inferred.

The target can also be a set. In this case the intersection will be the initially selected elements.

public Select ( string target, IEnumerable dataSource, IDictionary attributes ) : string
target string The object to get the value from and to be based on to create the element name.
dataSource IEnumerable The set of available elements
attributes IDictionary Attributes for the FormHelper method and for the html element it generates
return string

Select() public method

Creates a select element and its options based on the dataSource. If the dataSource elements are complex objects (ie not string or primitives), supply the parameters value and text to the dictionary to make the helper use the specified properties to extract the option value and content respectively.

You can also specify the attribute firstoption to force the first option be something like 'please select'. You can set the value of firstoption by specifying the attribute firstoptionvalue. The default value is '0'.

Usually the target is a single value and the dataSource is obviously a set with multiple items. The element types tend to be the same. If they are not, you might have to specify the suffix parameters on the attributes as it would not be inferred.

The target can also be a set. In this case the intersection will be the initially selected elements.

public Select ( string target, object selectedValue, IEnumerable dataSource, IDictionary attributes ) : string
target string The object to get the value from and to be based on to create the element name.
selectedValue object
dataSource IEnumerable The set of available elements
attributes IDictionary Attributes for the FormHelper method and for the html element it generates
return string

Service() public method

Invoked by the framework in order to give a chance to obtain other services
public Service ( IServiceProvider provider ) : void
provider IServiceProvider The service proviver
return void

Submit() public method

Generates an input submit element.
public Submit ( string value ) : string
value string The value/caption for the button.
return string

Submit() public method

Generates an input submit element.
public Submit ( string value, IDictionary attributes ) : string
value string The value/caption for the button.
attributes IDictionary Attributes for the FormHelper method and for the html element it generates
return string

TextArea() public method

Generates a textarea element.

The value is extracted from the target (if available)

public TextArea ( string target ) : string
target string The object to get the value from and to be based on to create the element name.
return string

TextArea() public method

Generates a textarea element.

The value is extracted from the target (if available)

public TextArea ( string target, IDictionary attributes ) : string
target string The object to get the value from and to be based on to create the element name.
attributes IDictionary Attributes for the FormHelper method and for the html element it generates
return string

TextAreaValue() public method

Generates a textarea element with a specified value.
public TextAreaValue ( string target, object value, IDictionary attributes ) : string
target string The target to base the element name on.
value object The value to apply to the field.
attributes IDictionary Attributes for the FormHelper method and for the html element it generates
return string

TextField() public method

Generates an input text element.

The value is extracted from the target (if available)

public TextField ( string target ) : string
target string The object to get the value from and to be based on to create the element name.
return string

TextField() public method

Generates an input text element.

The value is extracted from the target (if available)

public TextField ( string target, IDictionary attributes ) : string
target string The object to get the value from and to be based on to create the element name.
attributes IDictionary Attributes for the FormHelper method and for the html element it generates
return string

TextFieldValue() public method

Generates an input text form element with the supplied value
public TextFieldValue ( string target, object value ) : string
target string The string to be used to create the element name.
value object Value to supply to the element (instead of querying the target)
return string

TextFieldValue() public method

Generates an input text form element with the supplied value
public TextFieldValue ( string target, object value, IDictionary attributes ) : string
target string The string to be used to create the element name.
value object Value to supply to the element (instead of querying the target)
attributes IDictionary Attributes for the FormHelper method and for the html element it generates
return string

UsePrototypeValidation() public method

Configures this FormHelper instance to use Prototype for form fields validation
public UsePrototypeValidation ( ) : void
return void

UseWebValidatorProvider() public method

Configures this FormHelper instance to use the supplied web validator to generate field validation.
public UseWebValidatorProvider ( IBrowserValidatorProvider provider ) : void
provider IBrowserValidatorProvider The validation provider.
return void

UseZebdaValidation() public method

Configures this FormHelper instance to use Zebda for form fields validation
public UseZebdaValidation ( ) : void
return void

UsefValidate() public method

Configures this FormHelper instance to use fValidate for form fields validation
public UsefValidate ( ) : void
return void

Property Details

FieldFlags protected static property

Common field flags for reflection
protected static BindingFlags FieldFlags
return BindingFlags

PropertyFlags protected static property

Common property flags for reflection
protected static BindingFlags PropertyFlags
return BindingFlags

PropertyFlags2 protected static property

Common property flags for reflection (with declared only)
protected static BindingFlags PropertyFlags2
return BindingFlags

logger protected property

Logger instance
protected ILogger logger
return ILogger