Sencha Documentation

This mixin provides a common interface for the logical behavior of form fields, including:

  • Getters, setters, and conversion methods for field values
  • Events and methods for tracking value and validity changes
  • Methods for triggering validation

When implementing custom fields, it is likely that you will want to extend the Ext.form.BaseField component class rather than using this mixin directly, as it contains additional logic for generating an actual DOM complete with label and error message display.

If you want to implement this mixin directly and don't want to extend Ext.form.BaseField, then you will most likely want to override the following methods with custom implementations: getRawValue, setRawValue, and getErrors. If your field implementation handles custom data types you may also want to override valueToRaw and rawToValue. Other methods may be overridden as needed but their base implementations should be sufficient for common cases.

Config Options

 
disabled : Boolean
True to disable the field (defaults to false). Disabled Fields will not be submitted.

True to disable the field (defaults to false). Disabled Fields will not be submitted.

 
name : String
The name of the field (defaults to undefined). This is used as the parameter name when including the field value in a...
The name of the field (defaults to undefined). This is used as the parameter name when including the field value in a form submit(). If no name is configured, it falls back to the inputId. To prevent the field from being included in the form submit, set submitValue to false.
 
submitValue : Boolean
Setting this to false will prevent the field from being submitted even when it is not disabled. Defaults to true.
Setting this to false will prevent the field from being submitted even when it is not disabled. Defaults to true.
 
Specifies whether this field should be validated immediately whenever a change in its value is detected. Defaults to ...

Specifies whether this field should be validated immediately whenever a change in its value is detected. Defaults to true. If the validation results in a change in the field's validity, a validitychange event will be fired. This allows the field to show feedback about the validity of its contents immediately as the user is typing.

When set to false, feedback will not be immediate. However the form will still be validated before submitting if the clientValidation option to Ext.form.Basic.doAction is enabled, or if the field or form are validated manually.

See also Ext.form.BaseField.checkChangeEventsfor controlling how changes to the field's value are detected.

 
value : Mixed
A value to initialize this field with (defaults to undefined).
A value to initialize this field with (defaults to undefined).

Properties

 
isFormField : Boolean} Flag denoting that this component is a Field. Always true.
 
The original value of the field as configured in the value configuration, or as loaded by the last form load operatio...
The original value of the field as configured in the value configuration, or as loaded by the last form load operation if the form's trackResetOnLoad setting is true.

Methods

 
Checks whether the value of the field has changed since the last time it was checked. If the value has changed, it: ...

Checks whether the value of the field has changed since the last time it was checked. If the value has changed, it:

  1. Fires the change event,
  2. Performs validation if the validateOnChange config is enabled, firing the validationchange event if the validity has changed, and
  3. Checks the dirty state of the field and fires the dirtychange event if it has changed.
 
Checks the isDirty state of the field and if it has changed since the last time it was checked, fires the dirtychange...
Checks the isDirty state of the field and if it has changed since the last time it was checked, fires the dirtychange event.
 
Validates the field and if its validity has changed since the last time it was checked, fires the validitychange even...
Validates the field and if its validity has changed since the last time it was checked, fires the validitychange event.
 
getErrors( Mixed value ) : Array
Runs this field's validators and returns an array of error messages for any validation failures. This is called inter...

Runs this field's validators and returns an array of error messages for any validation failures. This is called internally during validation and would not usually need to be used manually.

Each subclass should override or augment the return value to provide their own errors.

Parameters

  • value : Mixed
    The value to get errors for (defaults to the current field value)

Returns

  • Array   All error messages for this field; an empty Array if none.
 
getName : String
Returns the name attribute of the field. This is used as the parameter name when including the field value in a form ...
Returns the name attribute of the field. This is used as the parameter name when including the field value in a form submit().
 
getRawValue : String
Returns the raw value of the field, without performing any normalization, conversion, or validation. To get a normali...
Returns the raw value of the field, without performing any normalization, conversion, or validation. To get a normalized and converted value see getValue.
 
Returns the value that would be included in a standard form submit for this field. This will be combined with the fie...

Returns the value that would be included in a standard form submit for this field. This will be combined with the field's name to form a name=value pair in the submitted parameters. If an empty string is returned then just the name= will be submitted; if null is returned then nothing will be submitted.

Note that the value returned will have been processed but may or may not have been successfully validated.

 
getValue : Mixed
Returns the current data value of the field. The type of value returned is particular to the type of the particular f...
Returns the current data value of the field. The type of value returned is particular to the type of the particular field (e.g. a Date object for Ext.form.Date), as the result of calling rawToValue on the field's processed String value. To return the raw String value, see getRawValue.
 
initField : Void
Initializes this Field mixin on the current instance. Components using this mixin should call this method during thei...
Initializes this Field mixin on the current instance. Components using this mixin should call this method during their own initialization process.
 
isDirty : Boolean
Returns true if the value of this Field has been changed from its originalValue. Will always return false if the fiel...

Returns true if the value of this Field has been changed from its originalValue. Will always return false if the field is disabled.

Note that if the owning form was configured with trackResetOnLoad then the {@lnk #originalValue} is updated when the values are loaded by Ext.form.Basic.setValues.

 
isValid : Boolean
Returns whether or not the field value is currently valid by validating the field's current value. Note: disabled fie...

Returns whether or not the field value is currently valid by validating the field's current value. Note: disabled fields are always treated as valid.

Logically this is identical to the validate method, but implementations are encouraged to ensure that this method does not have side-effects such as triggering error message display.

 
processRawValue( Mixed value ) : Mixed
Performs any necessary manipulation of a raw field value to prepare it for conversion and/or validation, for instance...
Performs any necessary manipulation of a raw field value to prepare it for conversion and/or validation, for instance stripping out ignored characters. In the base implementation it does nothing; individual subclasses may override this as needed.

Parameters

  • value : Mixed
    The unprocessed string value

Returns

  • Mixed   The processed string value
 
rawToValue( Mixed rawValue ) : Mixed
Converts a raw input field value into a mixed-type value that is suitable for this particular field type. This allows...

Converts a raw input field value into a mixed-type value that is suitable for this particular field type. This allows controlling the normalization and conversion of user-entered values into field-type-appropriate values, e.g. a Date object for Ext.form.Date, and is invoked by getValue.

It is up to individual implementations to decide how to handle raw values that cannot be successfully converted to the desired object type.

See valueToRaw for the opposite conversion.

The base implementation does no conversion, returning the raw value untouched.

Parameters

  • rawValue : Mixed

Returns

  • Mixed   The converted value.
 
reset : Void
Resets the current field value to the originally loaded value and clears any validation messages. See Ext.form.Basic....
Resets the current field value to the originally loaded value and clears any validation messages. See Ext.form.Basic.trackResetOnLoad
 
setRawValue( Mixed value ) : Mixed
Sets the field's raw value directly, bypassing value conversion, change detection, and validation. To set the value w...
Sets the field's raw value directly, bypassing value conversion, change detection, and validation. To set the value with these additional inspections see setValue.

Parameters

  • value : Mixed
    The value to set

Returns

  • Mixed   value The field value that is set
 
setValue( Mixed value ) : Ext.form.Field
Sets a data value into the field and runs the change detection and validation. To set the value directly without thes...
Sets a data value into the field and runs the change detection and validation. To set the value directly without these inspections see setRawValue.

Parameters

  • value : Mixed
    The value to set

Returns

  • Ext.form.Field   this
 
validate : Boolean
Returns whether or not the field value is currently valid by validating the field's current value. Note: disabled fie...

Returns whether or not the field value is currently valid by validating the field's current value. Note: disabled fields are always treated as valid.

Logically this is identical to the isValid method, but unlike that method this one may have side-effects such as triggering error message display.

 
valueToRaw( Mixed value ) : Mixed
Converts a mixed-type value to a raw representation suitable for displaying in the field. This allows controlling how...

Converts a mixed-type value to a raw representation suitable for displaying in the field. This allows controlling how value objects passed to setValue are shown to the user, including localization. For instance, for a Ext.form.Date, this would control how a Date object passed to setValue would be converted to a String for display in the field.

See rawToValue for the opposite conversion.

The base implementation simply does a standard toString conversion, and converts empty values to an empty string.

Parameters

  • value : Mixed
    The mixed-type value to convert to the raw representation.

Returns

  • Mixed   The converted raw value.

Events

 
change( Ext.form.Field this, Mixed newValue, Mixed oldValue )
Fires when a user-initiated change is detected in the value of the field.
Fires when a user-initiated change is detected in the value of the field.

Parameters

  • this : Ext.form.Field
  • newValue : Mixed
    The new value
  • oldValue : Mixed
    The original value

Returns

  • Void
 
dirtychange( Ext.form.Field this, Boolean isDirty )
Fires when a change in the field's isDirty state is detected.
Fires when a change in the field's isDirty state is detected.

Parameters

  • this : Ext.form.Field
  • isDirty : Boolean
    Whether or not the field is now dirty

Returns

  • Void
 
validitychange( Ext.form.Field this, Boolean isValid )
Fires when a change in the field's validity is detected.
Fires when a change in the field's validity is detected.

Parameters

  • this : Ext.form.Field
  • isValid : Boolean
    Whether or not the field is now valid

Returns

  • Void