Ext.ns('Application.Index');
 
Application.Index.AdvertiserForm = Ext.extend(Ext.form.FormPanel, {
	border:false,
	url: 'user/add',
	frame: true,
	labelWidth: 50,
	initComponent:function() {
		// build the form-fields.  Always a good idea to defer form-building to a method so that this class can
		// be over-ridden to provide different form-fields
		this.items = this.buildForm();
		Application.Index.AdvertiserForm.superclass.initComponent.apply(this, arguments);
    }, // eo function initComponent

 
	buttons: [{
		text: 'Зарегистрировать',
		handler: function(){
			this.getForm().submit( {
				success: function(form, action){ 
					obj = Ext.util.JSON.decode(action.response.responseText);
					window.location = obj.redirect.url;
				},
				failure:function(form, action){ 
					if(action.failureType == 'server'){ 
						obj = Ext.util.JSON.decode(action.response.responseText);
						//publisherErrorLabel.setText(obj.errors.reason);
					}
				} 
			});
		}
	}],
    
    buildForm : function() {
        return [
            {	
            	xtype: 'vbncombo'	
            },{
        		xtype: 'textfield',
        		fieldLabel: 'Логин',
        		name: 'nickname',
        		allowBlank: false,
        	},{
	      		xtype: 'hidden',
	    		name: 'role',
	    		value: 'advertiser'
        	},{
        		xtype: 'textfield',
        		fieldLabel: 'Пароль',
        		name: 'password',
        		allowBlank: false,
        	},{
        		xtype: 'textfield',
        		fieldLabel: 'Email',
        		name: 'email',
        		vtype: 'email',
        	},{
          		xtype: 'label'
        	}
        ];
    }
});
 
Ext.reg('indexadvertiserform', Application.Index.AdvertiserForm);
