Class: _Field

_Field()

Field is the base class for all field controls. It describes all the functions a field should support giving no implementation itself, merely a shell. The one function that `_Field` does provide that most fields leave untouched is `validate`. All fields are dijit Widgets meaning it goes through the same lifecycle and has all the Widget functionality.

Constructor

new _Field()

Source:
Requires:
  • module:argos.FieldManager

Requires

  • module:argos.FieldManager

Members

alwaysUseValue

Properties:
Name Type Description
Signifies Boolean that the field should always be included when the form calls getValues.
Source:

applyTo

Properties:
Name Type Description
If String defined it will use the applyTo string when getting and setting properties from the SData object instead of the `property` property.
Source:

autoFocus

Properties:
Name Type Description
Flag Boolean to indicate if this field should be focused when the form is shown.
Source:

containerNode

Properties:
Name Type Description
The HTMLElement parent container element of the field.
Source:

default

This applies a default value when inserting a new record, the default value is applied after the template entry but before the context and changes are applied. Note the word `default` must be in quotes as default is a reserved word in javascript.
Source:

disabled

Properties:
Name Type Description
Indicates Boolean the disabled state
Source:

hidden

Properties:
Name Type Description
Indicates Boolean the visibility state
Source:

label

Properties:
Name Type Description
The String text that will, by default, show to the left of a field.
Source:

name

Properties:
Name Type Description
The String unique (within the current form) name of the field
Source:

owner

Properties:
Name Type Description
View View that controls the field.
Source:

property

Properties:
Name Type Description
The String SData property that the field will be bound to.
Source:

type

Properties:
Name Type Description
The String registered name of the field that gets mapped in FieldManager when the field is constructed
Source:

widgetTemplate

Properties:
Name Type Description
Simplate Simplate used to define the fields HTML Markup
Source:

Methods

clearValue()

Each field type will need to implement this function to clear the value and visually.
Source:

disable()

Sets disabled to true and fires onDisable.
Source:

enable()

Sets disabled to false and fires onEnable.
Source:

focus()

Focuses the input for the field
Source:

getValue()

Each field type will need to implement this function to return the value of the field.
Source:

hide()

Sets hidden to true and fires onHide.
Source:

init()

Calledd during app startup after all fields have been inserted into the view
Source:

isDirty() → {Boolean}

Determines if the fields' value has changed from the original value. Each field type should override this function and provide one tailored to its datatype.
Source:
Returns:
True if the value has been modified (dirty).
Type
Boolean

isDisabled() → {Boolean}

Returns the disabled state
Source:
Returns:
Type
Boolean

isHidden() → {Boolean}

Returns the hidden state
Source:
Returns:
Type
Boolean

onChange(field)

Event that fires when the field is changed
Parameters:
Name Type Description
field _Field The field itself
Source:

onDisable(field)

Event that fires when the field is disabled
Parameters:
Name Type Description
field _Field The field itself
Source:

onEnable(field)

Event that fires when the field is enabled
Parameters:
Name Type Description
field _Field The field itself
Source:

onHide(field)

Event that fires when the field is hidden
Parameters:
Name Type Description
field _Field The field itself
Source:

onShow(field)

Event that fires when the field is shown
Parameters:
Name Type Description
field _Field The field itself
Source:

renderTo(node)

Inserts the field into the given DOM node using dijit Widget `placeAt(node)` and saves a reference to it to `this.containerNode`.
Parameters:
Name Type Description
node HTMLElement Target node to insert the field into
Source:

setValue(val, initial)

Each field type will need to implement this function to set the value and represent the change visually.
Parameters:
Name Type Description
val String/Boolean/Number/Object The value to set
initial Boolean If true the value is meant to be the default/original/clean value.
Source:

show()

Sets hidden to false and fires onShow.
Source:

validate(value) → {Boolean/Object}

The validate function determines if there is any errors - meaning it will return false for a "Error free" field. ###Basic Flow: * loops over each `validator` defined on the field * Evaluate the result * If the validator is a RegExp, use return `!regExp.test(value)` * If the validator is a function, call and return the result of the function passing the value, _Field instance, and the `owner` property. * If the validator is an object and has a `test` key, follow the RegExp path. * If the validator is an object and has a `fn` key, follow the function path. * If the result is true and the validator is an object with a `message` key: * If message is a function, call and return the result of the function passing the value, _Field instance and the `owner` property. * Otherwise, assume it is a string format and call dojo's `string.substitute` using the message as the format, `${0}` as the value, `${1}` as the fields name, `${2}` as the fields label property. * Save the result of the function or string substitution as the result itself. * Return the result.
Parameters:
Name Type Description
value Value of the field, if not passed then getValue is used.
Source:
Returns:
False signifies that everything is okay and the field is valid, `true` or a `string message` indicates that it failed.
Type
Boolean/Object

_Field(o)

new _Field(o)

Passed options object will be mixed into the field, overwriting any defaults.
Parameters:
Name Type Description
o Object Override options
Source:

Members

alwaysUseValue

Properties:
Name Type Description
Signifies Boolean that the field should always be included when the form calls getValues.
Source:

applyTo

Properties:
Name Type Description
If String defined it will use the applyTo string when getting and setting properties from the SData object instead of the `property` property.
Source:

autoFocus

Properties:
Name Type Description
Flag Boolean to indicate if this field should be focused when the form is shown.
Source:

containerNode

Properties:
Name Type Description
The HTMLElement parent container element of the field.
Source:

default

This applies a default value when inserting a new record, the default value is applied after the template entry but before the context and changes are applied. Note the word `default` must be in quotes as default is a reserved word in javascript.
Source:

disabled

Properties:
Name Type Description
Indicates Boolean the disabled state
Source:

hidden

Properties:
Name Type Description
Indicates Boolean the visibility state
Source:

label

Properties:
Name Type Description
The String text that will, by default, show to the left of a field.
Source:

name

Properties:
Name Type Description
The String unique (within the current form) name of the field
Source:

owner

Properties:
Name Type Description
View View that controls the field.
Source:

property

Properties:
Name Type Description
The String SData property that the field will be bound to.
Source:

type

Properties:
Name Type Description
The String registered name of the field that gets mapped in FieldManager when the field is constructed
Source:

widgetTemplate

Properties:
Name Type Description
Simplate Simplate used to define the fields HTML Markup
Source:

Methods

clearValue()

Each field type will need to implement this function to clear the value and visually.
Source:

disable()

Sets disabled to true and fires onDisable.
Source:

enable()

Sets disabled to false and fires onEnable.
Source:

focus()

Focuses the input for the field
Source:

getValue()

Each field type will need to implement this function to return the value of the field.
Source:

hide()

Sets hidden to true and fires onHide.
Source:

init()

Calledd during app startup after all fields have been inserted into the view
Source:

isDirty() → {Boolean}

Determines if the fields' value has changed from the original value. Each field type should override this function and provide one tailored to its datatype.
Source:
Returns:
True if the value has been modified (dirty).
Type
Boolean

isDisabled() → {Boolean}

Returns the disabled state
Source:
Returns:
Type
Boolean

isHidden() → {Boolean}

Returns the hidden state
Source:
Returns:
Type
Boolean

onChange(field)

Event that fires when the field is changed
Parameters:
Name Type Description
field _Field The field itself
Source:

onDisable(field)

Event that fires when the field is disabled
Parameters:
Name Type Description
field _Field The field itself
Source:

onEnable(field)

Event that fires when the field is enabled
Parameters:
Name Type Description
field _Field The field itself
Source:

onHide(field)

Event that fires when the field is hidden
Parameters:
Name Type Description
field _Field The field itself
Source:

onShow(field)

Event that fires when the field is shown
Parameters:
Name Type Description
field _Field The field itself
Source:

renderTo(node)

Inserts the field into the given DOM node using dijit Widget `placeAt(node)` and saves a reference to it to `this.containerNode`.
Parameters:
Name Type Description
node HTMLElement Target node to insert the field into
Source:

setValue(val, initial)

Each field type will need to implement this function to set the value and represent the change visually.
Parameters:
Name Type Description
val String/Boolean/Number/Object The value to set
initial Boolean If true the value is meant to be the default/original/clean value.
Source:

show()

Sets hidden to false and fires onShow.
Source:

validate(value) → {Boolean/Object}

The validate function determines if there is any errors - meaning it will return false for a "Error free" field. ###Basic Flow: * loops over each `validator` defined on the field * Evaluate the result * If the validator is a RegExp, use return `!regExp.test(value)` * If the validator is a function, call and return the result of the function passing the value, _Field instance, and the `owner` property. * If the validator is an object and has a `test` key, follow the RegExp path. * If the validator is an object and has a `fn` key, follow the function path. * If the result is true and the validator is an object with a `message` key: * If message is a function, call and return the result of the function passing the value, _Field instance and the `owner` property. * Otherwise, assume it is a string format and call dojo's `string.substitute` using the message as the format, `${0}` as the value, `${1}` as the fields name, `${2}` as the fields label property. * Save the result of the function or string substitution as the result itself. * Return the result.
Parameters:
Name Type Description
value Value of the field, if not passed then getValue is used.
Source:
Returns:
False signifies that everything is okay and the field is valid, `true` or a `string message` indicates that it failed.
Type
Boolean/Object