/** 
 * Ext form Field Override
 * 
 * @author Michael LeComte 
 * @copyright (c) 2008 
 * @date August 5, 2008 
 * 
 * @class Ext.form.Field
 * @extends Ext.BoxComponent
 * Tooltips on form fields
 * By default you cannot have tooltips on form fields 
 * This is because by default tooltips are used to display validation messages.
 * To override this and use tooltips to display user help you first need to 
 * override the default onRender action for form fields as follows
 * http://www.rowlands-bcs.com/?q=node/11
 */

Ext.override(Ext.form.Field, {
    onRender : function(ct, position){
        Ext.form.Field.superclass.onRender.call(this, ct, position);
        if(!this.el){
            var cfg = this.getAutoCreate();
            if(!cfg.name){
                cfg.name = this.name || this.id;
            }
            if(this.inputType){
                cfg.type = this.inputType;
            }
            //The rest of the onRender function is unchanged except here:
            //This code allows for the definition of a tooltip config object
            //with a tip and optional width
            if(this.tooltip){
                cfg['ext:qtip'] = this.tooltip.tip;
                cfg['ext:qwidth'] = this.tooltip.width || 100;
            }
            this.el = ct.createChild(cfg, position);
        }
        var type = this.el.dom.type;
        if(type){
            if(type == 'password'){
                type = 'text';
            }
            this.el.addClass('x-form-'+type);
        }
        if(this.readOnly){
            this.el.dom.readOnly = true;
        }
        if(this.tabIndex !== undefined){
            this.el.dom.setAttribute('tabIndex', this.tabIndex);
        }
        
        this.el.addClass([this.fieldClass, this.cls]);
        this.initValue();
    }
});

