Ext.override(Ext.form.Field,{
	initComponent : Ext.form.Field.prototype.initComponent.createSequence(function() {
		if (this._nodeId) {
			if (this.inputType!='file')
				this.dataIndex = (this.name ? this.name : ('field_'+this._nodeId));
			this.initialName = (this.name ? this.name : ('field_'+this._nodeId));
			this.name = 'data[data]['+(this.name ? this.name : ('field_'+this._nodeId))+']';
		}
	})
});

Ext.override(Ext.form.HtmlEditor,{
	initComponent : Ext.form.HtmlEditor.prototype.initComponent.createSequence(function() {
		if (this._nodeId) {
			this.dataIndex = (this.name ? this.name : ('field_'+this._nodeId));
			this.initialName = this.dataIndex;
			this.name = 'data[data]['+this.dataIndex+']';
		}
	})
});

Ext.apply(Ext.form.VTypes, {
    '(none)':  function(v) {return true}
});

//Ext.override(Ext.ux.form.FormPanel,{
//	onRender : Ext.ux.form.FormPanel.prototype.onRender.createSequence(function() {
//		this.form.reader = new Ext.data.JsonReader({
//			root: 'results',
//			id: 'id'
//		},this.dataArray);
//	}),
//	afterRender : Ext.ux.form.FormPanel.prototype.afterRender.createSequence(function() {
//		if (this.data_id) {
//			this.on('actioncomplete', function(form, action) {
//				if (action.type=='load') {
//					if (this.el.hasClass('webform_viewResults')) {
//						var r = Ext.decode(action.response.responseText).results[0];
//						this.cascade(function(c) {
//							// upload fields
//			        		if ((c instanceof Ext.form.TextField) && c.inputType=='file') {
//			        			if (r[c.initialName]) {
//			        				var div = document.createElement('div');
//			        				div.style.padding = '3px 0 0 4px';
//			        				var link = document.createElement('a');
//			        				link.href = r[c.initialName];
//			        				link['className'] = 'link';
//			        				var text = r[c.initialName].split('/');
//			        				link.innerHTML = text[text.length-1];
//			        				div.appendChild(link);
//			        				c.el.parent().appendChild(div);
//			        			}
//			        		}
//			        		// textarea
//			        		if ((c instanceof Ext.form.TextArea)) {
//		        				var div = document.createElement('div');
//		        				div.style.padding = '3px 0 0 4px';
//		        				div.style.color = '#444';
//		        				div.innerHTML = c.getValue();
//		        				var p = c.el.parent();
//		        				c.el.remove();
//		        				p.appendChild(div);
//			        		}
//			        		// html editor
//			        		if ((c instanceof Ext.form.HtmlEditor)) {
//			        			var p = c.el.parent();
//			        			var v = c.getValue();
//			        			while (p.first()) p.first().remove();
//			        			
//		        				var div = document.createElement('div');
//		        				div.style.padding = '3px 0 0 4px';
//		        				div.style.display = 'block';
//		        				div.style.color = '#444';
//		        				div.innerHTML = v;
//		        				p.appendChild(div);
//			        		}
//			        		// captcha
//			        		if ((c instanceof Ext.ux.form.Captcha)) {
//			        			c.el.parent().parent().remove();
//			        		}
//			        	});
//					}
//				}
//			},this);
//			this.form.load({url: '/webforms/getFormResults/'+this.data_id,waitMsg: 'Loading...'});
//		}
//		if (!this.el.hasClass('webform_viewResults')) {
//			this.cascade(function(c) {
//        		// dual-fields
//        		if (c.dualField) {
//        			c.validator = function(v) {
//        				var dual = this.find('initialName',c.dualField)[0];
//        				if (dual && dual.getValue()==c.getValue()) {
//        					return true;
//        				}
//        				return 'This value should be the same as the "'+c.dualField+'" field.';
//        			}.createDelegate(this);
//        		}
//        	},this);
//		}
//	})
//});
