Sencha Documentation

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

  • Getter and setter methods for field values
  • Events and methods for tracking value and validity changes
  • Methods for triggering validation NOTE**: When implementing custom fields, it is most likely that you will want to extend the Ext.form.BaseField component class rather than using this mixin directly, as BaseField contains additional logic for generating an actual DOM complete with label and error message display and a form input field, plus methods that bind the Field value getters and setters to the input field's value.

If you do 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: getValue, setValue, and getErrors. Other methods may be overridden as needed but their base implementations should be sufficient for common cases. You will also need to make sure that initField is called during the component's initialization.

Defined By

Config Options

 
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.

 
The name of the field (defaults to undefined). By default this is used as the parameter name when including the field...
The name of the field (defaults to undefined). By default this is used as the parameter name when including the field value in a form submit(). To prevent the field from being included in the form submit, set submitValue to false.
 
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.

 
A value to initialize this field with (defaults to undefined).
A value to initialize this field with (defaults to undefined).
Defined By

Properties

 
isFormField : Boolean} Flag denoting that this component is a Field. Always true.
 
originalValue : Mixed The original value of the field as configured in the {@link #value} configuration, or as loaded by the last form load operation if the form's {@link Ext.form.Basic#trackResetOnLoad trackResetOnLoad} setting is <code>true</code>.
Defined By

Methods

 
areValuesEqual( Mixed value1, Mixed value2) : Boolean
Returns whether two field values are logically equal. Field implementations may override this to provide custom compa...
Returns whether two field values are logically equal. Field implementations may override this to provide custom comparison logic appropriate for the particular field's data type.

Parameters

  • value1 : Mixed
    The first value to compare
  • value2 : Mixed
    The second value to compare

Returns

  • Boolean   True if the values are equal, false if inequal.
 
A utility for grouping a set of modifications which may trigger value changes into a single transaction, to prevent e...
A utility for grouping a set of modifications which may trigger value changes into a single transaction, to prevent excessive firing of change events. This is useful for instance if the field has sub-fields which are being updated as a group; you don't want the container field to check its own changed state for each subfield change.

Parameters

  • A : fn
    function containing the transaction code

Returns

  • Void
 
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.

Returns

  • Void
 
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.

Returns

  • Void
 
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.
 
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().

Returns

  • String   name The field {@link Ext.form.Field#name name}
 
Returns the parameter(s) that would be included in a standard form submit for this field. Typically this will be an o...

Returns the parameter(s) that would be included in a standard form submit for this field. Typically this will be an object with a single name-value pair, the name being this field's name and the value being its current value. More advanced field implementations may return more than one name-value pair.

Note that the values returned from this method are not guaranteed to have been successfully validated.

Returns

  • Object   A mapping of submit parameter names to values; each value should be a string, or an array of strings if that particular name has multiple values. It can also return null if there are no parameters to be be submitted.
 
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).

Returns

  • Mixed   value The field value
 
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.

Returns

  • Void
 
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 originalValue is updated when the values are loaded by Ext.form.Basic.setValues.

Returns

  • Boolean   True if this field has been changed from its original value (and is not disabled), false otherwise.
 
Returns whether or not the field value is currently valid by validating the field's current value. The validitychange...

Returns whether or not the field value is currently valid by validating the field's current value. The validitychange event will not be fired; use validate instead if you want the event to fire. Note: disabled fields are always treated as valid.

Implementations are encouraged to ensure that this method does not have side-effects such as triggering error message display.

Returns

  • Boolean   True if the value is valid, else false
 
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

Returns

  • Void
 
Resets the field's originalValue property so it matches the current value. This is called by Ext.form.Basic.setValues...
Resets the field's originalValue property so it matches the current value. This is called by Ext.form.Basic.setValues if the form's trackResetOnLoad property is set to true.

Returns

  • Void
 
setValue( Mixed value) : Ext.form.Field
Sets a data value into the field and runs the change detection and validation.
Sets a data value into the field and runs the change detection and validation.

Parameters

  • value : Mixed
    The value to set

Returns

  • Ext.form.Field   this
 
Returns whether or not the field value is currently valid by validating the field's current value, and fires the vali...

Returns whether or not the field value is currently valid by validating the field's current value, and fires the validitychange event if the field's validity has changed since the last validation. Note: disabled fields are always treated as valid.

Custom implementations of this method are allowed to have side-effects such as triggering error message display. To validate without side-effects, use isValid.

Returns

  • Boolean   True if the value is valid, else false
Defined By

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