4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-form-field-Base-method-constructor'><span id='Ext-form-field-Base'>/**
19 </span></span> * @class Ext.form.field.Base
20 * @extends Ext.Component
22 Base class for form fields that provides default event handling, rendering, and other common functionality
23 needed by all form field types. Utilizes the {@link Ext.form.field.Field} mixin for value handling and validation,
24 and the {@link Ext.form.Labelable} mixin to provide label and error message display.
26 In most cases you will want to use a subclass, such as {@link Ext.form.field.Text} or {@link Ext.form.field.Checkbox},
27 rather than creating instances of this class directly. However if you are implementing a custom form field,
28 using this as the parent class is recommended.
30 __Values and Conversions__
32 Because BaseField implements the Field mixin, it has a main value that can be initialized with the
33 {@link #value} config and manipulated via the {@link #getValue} and {@link #setValue} methods. This main
34 value can be one of many data types appropriate to the current field, for instance a {@link Ext.form.field.Date Date}
35 field would use a JavaScript Date object as its value type. However, because the field is rendered as a HTML
36 input, this value data type can not always be directly used in the rendered field.
38 Therefore BaseField introduces the concept of a "raw value". This is the value of the rendered HTML input field,
39 and is normally a String. The {@link #getRawValue} and {@link #setRawValue} methods can be used to directly
40 work with the raw value, though it is recommended to use getValue and setValue in most cases.
42 Conversion back and forth between the main value and the raw value is handled by the {@link #valueToRaw} and
43 {@link #rawToValue} methods. If you are implementing a subclass that uses a non-String value data type, you
44 should override these methods to handle the conversion.
48 The content of the field body is defined by the {@link #fieldSubTpl} XTemplate, with its argument data
49 created by the {@link #getSubTplData} method. Override this template and/or method to create custom
51 {@img Ext.form.BaseField/Ext.form.BaseField.png Ext.form.BaseField BaseField component}
54 // A simple subclass of BaseField that creates a HTML5 search field. Redirects to the
55 // searchUrl when the Enter key is pressed.
56 Ext.define('Ext.form.SearchField', {
57 extend: 'Ext.form.field.Base',
58 alias: 'widget.searchfield',
62 // Config defining the search URL
63 searchUrl: 'http://www.google.com/search?q={0}',
65 // Add specialkey listener
66 initComponent: function() {
68 this.on('specialkey', this.checkEnterKey, this);
71 // Handle enter key presses, execute the search if the field has a value
72 checkEnterKey: function(field, e) {
73 var value = this.getValue();
74 if (e.getKey() === e.ENTER && !Ext.isEmpty(value)) {
75 location.href = Ext.String.format(this.searchUrl, value);
80 Ext.create('Ext.form.Panel', {
81 title: 'BaseField Example',
85 // Fields will be arranged vertically, stretched to full width
95 renderTo: Ext.getBody()
100 * @param {Object} config Configuration options
104 * @docauthor Jason Johnston <jason@sencha.com>
106 Ext.define('Ext.form.field.Base', {
107 extend: 'Ext.Component',
109 labelable: 'Ext.form.Labelable',
110 field: 'Ext.form.field.Field'
112 alias: 'widget.field',
113 alternateClassName: ['Ext.form.Field', 'Ext.form.BaseField'],
114 requires: ['Ext.util.DelayedTask', 'Ext.XTemplate', 'Ext.layout.component.field.Field'],
117 '<input id="{id}" type="{type}" ',
118 '<tpl if="name">name="{name}" </tpl>',
119 '<tpl if="size">size="{size}" </tpl>',
120 '<tpl if="tabIdx">tabIndex="{tabIdx}" </tpl>',
121 'class="{fieldCls} {typeCls}" autocomplete="off" />',
128 <span id='Ext-form-field-Base-cfg-name'> /**
129 </span> * @cfg {String} name The name of the field (defaults to undefined). This is used as the parameter
130 * name when including the field value in a {@link Ext.form.Basic#submit form submit()}. If no name is
131 * configured, it falls back to the {@link #inputId}. To prevent the field from being included in the
132 * form submit, set {@link #submitValue} to <tt>false</tt>.
135 <span id='Ext-form-field-Base-cfg-inputType'> /**
136 </span> * @cfg {String} inputType
137 * <p>The type attribute for input fields -- e.g. radio, text, password, file (defaults to <tt>'text'</tt>).
138 * The extended types supported by HTML5 inputs (url, email, etc.) may also be used, though using them
139 * will cause older browsers to fall back to 'text'.</p>
140 * <p>The type 'password' must be used to render that field type currently -- there is no separate Ext
141 * component for that. You can use {@link Ext.form.field.File} which creates a custom-rendered file upload
142 * field, but if you want a plain unstyled file input you can use a BaseField with inputType:'file'.</p>
146 <span id='Ext-form-field-Base-cfg-tabIndex'> /**
147 </span> * @cfg {Number} tabIndex The tabIndex for this field. Note this only applies to fields that are rendered,
148 * not those which are built via applyTo (defaults to undefined).
151 <span id='Ext-form-field-Base-cfg-invalidText'> /**
152 </span> * @cfg {String} invalidText The error text to use when marking a field invalid and no message is provided
153 * (defaults to 'The value in this field is invalid')
155 invalidText : 'The value in this field is invalid',
157 <span id='Ext-form-field-Base-cfg-fieldCls'> /**
158 </span> * @cfg {String} fieldCls The default CSS class for the field input (defaults to 'x-form-field')
160 fieldCls : Ext.baseCSSPrefix + 'form-field',
162 <span id='Ext-form-field-Base-cfg-fieldStyle'> /**
163 </span> * @cfg {String} fieldStyle Optional CSS style(s) to be applied to the {@link #inputEl field input element}.
164 * Should be a valid argument to {@link Ext.core.Element#applyStyles}. Defaults to undefined. See also the
165 * {@link #setFieldStyle} method for changing the style after initialization.
168 <span id='Ext-form-field-Base-cfg-focusCls'> /**
169 </span> * @cfg {String} focusCls The CSS class to use when the field receives focus (defaults to 'x-form-focus')
171 focusCls : Ext.baseCSSPrefix + 'form-focus',
173 <span id='Ext-form-field-Base-cfg-dirtyCls'> /**
174 </span> * @cfg {String} dirtyCls The CSS class to use when the field value {@link #isDirty is dirty}.
176 dirtyCls : Ext.baseCSSPrefix + 'form-dirty',
178 <span id='Ext-form-field-Base-cfg-checkChangeEvents'> /**
179 </span> * @cfg {Array} checkChangeEvents
180 * <p>A list of event names that will be listened for on the field's {@link #inputEl input element}, which
181 * will cause the field's value to be checked for changes. If a change is detected, the
182 * {@link #change change event} will be fired, followed by validation if the {@link #validateOnChange}
183 * option is enabled.</p>
184 * <p>Defaults to <tt>['change', 'propertychange']</tt> in Internet Explorer, and <tt>['change', 'input',
185 * 'textInput', 'keyup', 'dragdrop']</tt> in other browsers. This catches all the ways that field values
186 * can be changed in most supported browsers; the only known exceptions at the time of writing are:</p>
188 * <li>Safari 3.2 and older: cut/paste in textareas via the context menu, and dragging text into textareas</li>
189 * <li>Opera 10 and 11: dragging text into text fields and textareas, and cut via the context menu in text
190 * fields and textareas</li>
191 * <li>Opera 9: Same as Opera 10 and 11, plus paste from context menu in text fields and textareas</li>
193 * <p>If you need to guarantee on-the-fly change notifications including these edge cases, you can call the
194 * {@link #checkChange} method on a repeating interval, e.g. using {@link Ext.TaskManager}, or if the field is
195 * within a {@link Ext.form.Panel}, you can use the FormPanel's {@link Ext.form.Panel#pollForChanges}
196 * configuration to set up such a task automatically.</p>
198 checkChangeEvents: Ext.isIE && (!document.documentMode || document.documentMode < 9) ?
199 ['change', 'propertychange'] :
200 ['change', 'input', 'textInput', 'keyup', 'dragdrop'],
202 <span id='Ext-form-field-Base-cfg-checkChangeBuffer'> /**
203 </span> * @cfg {Number} checkChangeBuffer
204 * Defines a timeout in milliseconds for buffering {@link #checkChangeEvents} that fire in rapid succession.
205 * Defaults to 50 milliseconds.
207 checkChangeBuffer: 50,
209 componentLayout: 'field',
211 <span id='Ext-form-field-Base-cfg-readOnly'> /**
212 </span> * @cfg {Boolean} readOnly <tt>true</tt> to mark the field as readOnly in HTML
213 * (defaults to <tt>false</tt>).
214 * <br><p><b>Note</b>: this only sets the element's readOnly DOM attribute.
215 * Setting <code>readOnly=true</code>, for example, will not disable triggering a
216 * ComboBox or Date; it gives you the option of forcing the user to choose
217 * via the trigger without typing in the text box. To hide the trigger use
218 * <code>{@link Ext.form.field.Trigger#hideTrigger hideTrigger}</code>.</p>
222 <span id='Ext-form-field-Base-cfg-readOnlyCls'> /**
223 </span> * @cfg {String} readOnlyCls The CSS class applied to the component's main element when it is {@link #readOnly}.
225 readOnlyCls: Ext.baseCSSPrefix + 'form-readonly',
227 <span id='Ext-form-field-Base-cfg-inputId'> /**
228 </span> * @cfg {String} inputId
229 * The id that will be given to the generated input DOM element. Defaults to an automatically generated id.
230 * If you configure this manually, you must make sure it is unique in the document.
233 <span id='Ext-form-field-Base-cfg-validateOnBlur'> /**
234 </span> * @cfg {Boolean} validateOnBlur
235 * Whether the field should validate when it loses focus (defaults to <tt>true</tt>). This will cause fields
236 * to be validated as the user steps through the fields in the form regardless of whether they are making
237 * changes to those fields along the way. See also {@link #validateOnChange}.
239 validateOnBlur: true,
244 baseCls: Ext.baseCSSPrefix + 'field',
246 maskOnDisable: false,
249 initComponent : function() {
254 me.subTplData = me.subTplData || {};
257 <span id='Ext-form-field-Base-event-focus'> /**
258 </span> * @event focus
259 * Fires when this field receives input focus.
260 * @param {Ext.form.field.Base} this
263 <span id='Ext-form-field-Base-event-blur'> /**
264 </span> * @event blur
265 * Fires when this field loses input focus.
266 * @param {Ext.form.field.Base} this
269 <span id='Ext-form-field-Base-event-specialkey'> /**
270 </span> * @event specialkey
271 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed.
272 * To handle other keys see {@link Ext.panel.Panel#keys} or {@link Ext.util.KeyMap}.
273 * You can check {@link Ext.EventObject#getKey} to determine which key was pressed.
274 * For example: <pre><code>
275 var form = new Ext.form.Panel({
278 fieldLabel: 'Field 1',
282 fieldLabel: 'Field 2',
285 specialkey: function(field, e){
286 // e.HOME, e.END, e.PAGE_UP, e.PAGE_DOWN,
287 // e.TAB, e.ESC, arrow keys: e.LEFT, e.RIGHT, e.UP, e.DOWN
288 if (e.{@link Ext.EventObject#getKey getKey()} == e.ENTER) {
289 var form = field.up('form').getForm();
298 * </code></pre>
299 * @param {Ext.form.field.Base} this
300 * @param {Ext.EventObject} e The event object
309 // Default name to inputId
311 me.name = me.getInputId();
315 <span id='Ext-form-field-Base-method-getInputId'> /**
316 </span> * Returns the input id for this field. If none was specified via the {@link #inputId} config,
317 * then an id will be automatically generated.
319 getInputId: function() {
320 return this.inputId || (this.inputId = Ext.id());
323 <span id='Ext-form-field-Base-method-getSubTplData'> /**
324 </span> * @protected Creates and returns the data object to be used when rendering the {@link #fieldSubTpl}.
325 * @return {Object} The template data
327 getSubTplData: function() {
330 inputId = me.getInputId();
332 return Ext.applyIf(me.subTplData, {
334 name: me.name || inputId,
338 fieldCls: me.fieldCls,
340 typeCls: Ext.baseCSSPrefix + 'form-' + (type === 'password' ? 'text' : type)
344 <span id='Ext-form-field-Base-method-getSubTplMarkup'> /**
346 * Gets the markup to be inserted into the outer template's bodyEl. For fields this is the
347 * actual input element.
349 getSubTplMarkup: function() {
350 return this.getTpl('fieldSubTpl').apply(this.getSubTplData());
353 initRenderTpl: function() {
355 if (!me.hasOwnProperty('renderTpl')) {
356 me.renderTpl = me.getTpl('labelableRenderTpl');
358 return me.callParent();
361 initRenderData: function() {
362 return Ext.applyIf(this.callParent(), this.getLabelableRenderData());
365 <span id='Ext-form-field-Base-method-setFieldStyle'> /**
366 </span> * Set the {@link #fieldStyle CSS style} of the {@link #inputEl field input element}.
367 * @param {String/Object/Function} style The style(s) to apply. Should be a valid argument to
368 * {@link Ext.core.Element#applyStyles}.
370 setFieldStyle: function(style) {
372 inputEl = me.inputEl;
374 inputEl.applyStyles(style);
376 me.fieldStyle = style;
380 onRender : function() {
382 fieldStyle = me.fieldStyle,
383 renderSelectors = me.renderSelectors;
385 Ext.applyIf(renderSelectors, me.getLabelableSelectors());
387 Ext.applyIf(renderSelectors, {
388 <span id='Ext-form-field-Base-property-inputEl'> /**
389 </span> * @property inputEl
390 * @type Ext.core.Element
391 * The input Element for this Field. Only available after the field has been rendered.
393 inputEl: '.' + me.fieldCls
396 me.callParent(arguments);
398 // Make the stored rawValue get set as the input element's value
399 me.setRawValue(me.rawValue);
402 me.setReadOnly(true);
408 me.setFieldStyle(fieldStyle);
411 me.renderActiveError();
414 initAria: function() {
418 // Associate the field to the error message element
419 me.getActionEl().dom.setAttribute('aria-describedby', Ext.id(me.errorEl));
422 getFocusEl: function() {
426 isFileUpload: function() {
427 return this.inputType === 'file';
430 extractFileInput: function() {
432 fileInput = me.isFileUpload() ? me.inputEl.dom : null,
435 clone = fileInput.cloneNode(true);
436 fileInput.parentNode.replaceChild(clone, fileInput);
437 me.inputEl = Ext.get(clone);
442 // private override to use getSubmitValue() as a convenience
443 getSubmitData: function() {
447 if (!me.disabled && me.submitValue && !me.isFileUpload()) {
448 val = me.getSubmitValue();
451 data[me.getName()] = val;
457 <span id='Ext-form-field-Base-method-getSubmitValue'> /**
458 </span> * <p>Returns the value that would be included in a standard form submit for this field. This will be combined
459 * with the field's name to form a <tt>name=value</tt> pair in the {@link #getSubmitData submitted parameters}.
460 * If an empty string is returned then just the <tt>name=</tt> will be submitted; if <tt>null</tt> is returned
461 * then nothing will be submitted.</p>
462 * <p>Note that the value returned will have been {@link #processRawValue processed} but may or may not have
463 * been successfully {@link #validate validated}.</p>
464 * @return {String} The value to be submitted, or <tt>null</tt>.
466 getSubmitValue: function() {
467 return this.processRawValue(this.getRawValue());
470 <span id='Ext-form-field-Base-method-getRawValue'> /**
471 </span> * Returns the raw value of the field, without performing any normalization, conversion, or validation.
472 * To get a normalized and converted value see {@link #getValue}.
473 * @return {String} value The raw String value of the field
475 getRawValue: function() {
477 v = (me.inputEl ? me.inputEl.getValue() : Ext.value(me.rawValue, ''));
482 <span id='Ext-form-field-Base-method-setRawValue'> /**
483 </span> * Sets the field's raw value directly, bypassing {@link #valueToRaw value conversion}, change detection, and
484 * validation. To set the value with these additional inspections see {@link #setValue}.
485 * @param {Mixed} value The value to set
486 * @return {Mixed} value The field value that is set
488 setRawValue: function(value) {
490 value = Ext.value(value, '');
493 // Some Field subclasses may not render an inputEl
495 me.inputEl.dom.value = value;
500 <span id='Ext-form-field-Base-method-valueToRaw'> /**
501 </span> * <p>Converts a mixed-type value to a raw representation suitable for displaying in the field. This allows
502 * controlling how value objects passed to {@link #setValue} are shown to the user, including localization.
503 * For instance, for a {@link Ext.form.field.Date}, this would control how a Date object passed to {@link #setValue}
504 * would be converted to a String for display in the field.</p>
505 * <p>See {@link #rawToValue} for the opposite conversion.</p>
506 * <p>The base implementation simply does a standard toString conversion, and converts
507 * {@link Ext#isEmpty empty values} to an empty string.</p>
508 * @param {Mixed} value The mixed-type value to convert to the raw representation.
509 * @return {Mixed} The converted raw value.
511 valueToRaw: function(value) {
512 return '' + Ext.value(value, '');
515 <span id='Ext-form-field-Base-method-rawToValue'> /**
516 </span> * <p>Converts a raw input field value into a mixed-type value that is suitable for this particular field type.
517 * This allows controlling the normalization and conversion of user-entered values into field-type-appropriate
518 * values, e.g. a Date object for {@link Ext.form.field.Date}, and is invoked by {@link #getValue}.</p>
519 * <p>It is up to individual implementations to decide how to handle raw values that cannot be successfully
520 * converted to the desired object type.</p>
521 * <p>See {@link #valueToRaw} for the opposite conversion.</p>
522 * <p>The base implementation does no conversion, returning the raw value untouched.</p>
523 * @param {Mixed} rawValue
524 * @return {Mixed} The converted value.
526 rawToValue: function(rawValue) {
530 <span id='Ext-form-field-Base-method-processRawValue'> /**
531 </span> * Performs any necessary manipulation of a raw field value to prepare it for {@link #rawToValue conversion}
532 * and/or {@link #validate validation}, for instance stripping out ignored characters. In the base implementation
533 * it does nothing; individual subclasses may override this as needed.
534 * @param {Mixed} value The unprocessed string value
535 * @return {Mixed} The processed string value
537 processRawValue: function(value) {
541 <span id='Ext-form-field-Base-method-getValue'> /**
542 </span> * Returns the current data value of the field. The type of value returned is particular to the type of the
543 * particular field (e.g. a Date object for {@link Ext.form.field.Date}), as the result of calling {@link #rawToValue} on
544 * the field's {@link #processRawValue processed} String value. To return the raw String value, see {@link #getRawValue}.
545 * @return {Mixed} value The field value
547 getValue: function() {
549 val = me.rawToValue(me.processRawValue(me.getRawValue()));
554 <span id='Ext-form-field-Base-method-setValue'> /**
555 </span> * Sets a data value into the field and runs the change detection and validation. To set the value directly
556 * without these inspections see {@link #setRawValue}.
557 * @param {Mixed} value The value to set
558 * @return {Ext.form.field.Field} this
560 setValue: function(value) {
562 me.setRawValue(me.valueToRaw(value));
563 return me.mixins.field.setValue.call(me, value);
568 onDisable: function() {
570 inputEl = me.inputEl;
573 inputEl.dom.disabled = true;
578 onEnable: function() {
580 inputEl = me.inputEl;
583 inputEl.dom.disabled = false;
587 <span id='Ext-form-field-Base-method-setReadOnly'> /**
588 </span> * Sets the read only state of this field.
589 * @param {Boolean} readOnly Whether the field should be read only.
591 setReadOnly: function(readOnly) {
593 inputEl = me.inputEl;
595 inputEl.dom.readOnly = readOnly;
596 inputEl.dom.setAttribute('aria-readonly', readOnly);
598 me[readOnly ? 'addCls' : 'removeCls'](me.readOnlyCls);
599 me.readOnly = readOnly;
603 fireKey: function(e){
604 if(e.isSpecialKey()){
605 this.fireEvent('specialkey', this, Ext.create('Ext.EventObjectImpl', e));
610 initEvents : function(){
612 inputEl = me.inputEl,
616 me.mon(inputEl, Ext.EventManager.getKeyEvent(), me.fireKey, me);
617 me.mon(inputEl, 'focus', me.onFocus, me);
619 // standardise buffer across all browsers + OS-es for consistent event order.
620 // (the 10ms buffer for Editors fixes a weird FF/Win editor issue when changing OS window focus)
621 me.mon(inputEl, 'blur', me.onBlur, me, me.inEditor ? {buffer:10} : null);
623 // listen for immediate value changes
624 onChangeTask = Ext.create('Ext.util.DelayedTask', me.checkChange, me);
625 me.onChangeEvent = onChangeEvent = function() {
626 onChangeTask.delay(me.checkChangeBuffer);
628 Ext.each(me.checkChangeEvents, function(eventName) {
629 if (eventName === 'propertychange') {
630 me.usesPropertychange = true;
632 me.mon(inputEl, eventName, onChangeEvent);
638 doComponentLayout: function() {
640 inputEl = me.inputEl,
641 usesPropertychange = me.usesPropertychange,
642 ename = 'propertychange',
643 onChangeEvent = me.onChangeEvent;
645 // In IE if propertychange is one of the checkChangeEvents, we need to remove
646 // the listener prior to layout and re-add it after, to prevent it from firing
647 // needlessly for attribute and style changes applied to the inputEl.
648 if (usesPropertychange) {
649 me.mun(inputEl, ename, onChangeEvent);
651 me.callParent(arguments);
652 if (usesPropertychange) {
653 me.mon(inputEl, ename, onChangeEvent);
658 preFocus: Ext.emptyFn,
661 onFocus: function() {
663 focusCls = me.focusCls,
664 inputEl = me.inputEl;
666 if (focusCls && inputEl) {
667 inputEl.addCls(focusCls);
671 me.fireEvent('focus', me);
676 beforeBlur : Ext.emptyFn,
681 focusCls = me.focusCls,
682 inputEl = me.inputEl;
684 if (focusCls && inputEl) {
685 inputEl.removeCls(focusCls);
687 if (me.validateOnBlur) {
691 me.fireEvent('blur', me);
696 postBlur : Ext.emptyFn,
699 <span id='Ext-form-field-Base-method-onDirtyChange'> /**
700 </span> * @private Called when the field's dirty state changes. Adds/removes the {@link #dirtyCls} on the main element.
701 * @param {Boolean} isDirty
703 onDirtyChange: function(isDirty) {
704 this[isDirty ? 'addCls' : 'removeCls'](this.dirtyCls);
708 <span id='Ext-form-field-Base-method-isValid'> /**
709 </span> * Returns whether or not the field value is currently valid by
710 * {@link #getErrors validating} the {@link #processRawValue processed raw value}
711 * of the field. <b>Note</b>: {@link #disabled} fields are always treated as valid.
712 * @return {Boolean} True if the value is valid, else false
714 isValid : function() {
716 return me.disabled || me.validateValue(me.processRawValue(me.getRawValue()));
720 <span id='Ext-form-field-Base-method-validateValue'> /**
721 </span> * <p>Uses {@link #getErrors} to build an array of validation errors. If any errors are found, they are passed
722 * to {@link #markInvalid} and false is returned, otherwise true is returned.</p>
723 * <p>Previously, subclasses were invited to provide an implementation of this to process validations - from 3.2
724 * onwards {@link #getErrors} should be overridden instead.</p>
725 * @param {Mixed} value The value to validate
726 * @return {Boolean} True if all validations passed, false if one or more failed
728 validateValue: function(value) {
730 errors = me.getErrors(value),
731 isValid = Ext.isEmpty(errors);
732 if (!me.preventMark) {
736 me.markInvalid(errors);
743 <span id='Ext-form-field-Base-method-markInvalid'> /**
744 </span> * <p>Display one or more error messages associated with this field, using {@link #msgTarget} to determine how to
745 * display the messages and applying {@link #invalidCls} to the field's UI element.</p>
746 * <p><b>Note</b>: this method does not cause the Field's {@link #validate} or {@link #isValid} methods to
747 * return <code>false</code> if the value does <i>pass</i> validation. So simply marking a Field as invalid
748 * will not prevent submission of forms submitted with the {@link Ext.form.action.Submit#clientValidation}
749 * option set.</p>
750 * @param {String/Array} errors The validation message(s) to display.
752 markInvalid : function(errors) {
753 // Save the message and fire the 'invalid' event
755 oldMsg = me.getActiveError();
756 me.setActiveErrors(Ext.Array.from(errors));
757 if (oldMsg !== me.getActiveError()) {
758 me.doComponentLayout();
762 <span id='Ext-form-field-Base-method-clearInvalid'> /**
763 </span> * <p>Clear any invalid styles/messages for this field.</p>
764 * <p><b>Note</b>: this method does not cause the Field's {@link #validate} or {@link #isValid} methods to
765 * return <code>true</code> if the value does not <i>pass</i> validation. So simply clearing a field's errors
766 * will not necessarily allow submission of forms submitted with the {@link Ext.form.action.Submit#clientValidation}
767 * option set.</p>
769 clearInvalid : function() {
770 // Clear the message and fire the 'valid' event
772 hadError = me.hasActiveError();
773 me.unsetActiveError();
775 me.doComponentLayout();
779 <span id='Ext-form-field-Base-method-renderActiveError'> /**
780 </span> * @private Overrides the method from the Ext.form.Labelable mixin to also add the invalidCls to the inputEl,
781 * as that is required for proper styling in IE with nested fields (due to lack of child selector)
783 renderActiveError: function() {
785 hasError = me.hasActiveError();
787 // Add/remove invalid class
788 me.inputEl[hasError ? 'addCls' : 'removeCls'](me.invalidCls + '-field');
790 me.mixins.labelable.renderActiveError.call(me);
794 getActionEl: function() {
795 return this.inputEl || this.el;