/**
 * Blind that contains an Ext.form.FormPanel.
 */
Ext.ux.FormBlind = function(el, win, config) {
    Ext.ux.FormBlind.superclass.constructor.call(this, el, win, config);
    this.form = new Ext.FormPanel(this.formConfig);
};

Ext.extend(Ext.ux.FormBlind, Ext.ux.WindowBlind, { 
    /**
     * Render the form to the body el prior to the first show.
     */
    onBeforeShow: function() {
        if (!this.form.rendered) {
            this.form.render(this.body);                
        }
    
        Ext.ux.FormBlind.superclass.onBeforeShow.call(this);
    },
    
    /**
     * Override to add the button to the form versus the blind's own button container.
     * All buttons should be added prior to the first show, ie when the form is initially
     * rendered.
     * @param {String/Object} config A string becomes the button text, an object can be a Button config
     * object
     * @param {Function} handler The function called when the button is clicked
     * @param {Object} scope (optional) The scope of the handler function
     * @return {Ext.Button}
     */
    addButton : function(config, handler, scope) {
        var btn = this.form.addButton(this.getButtonConfig(config, handler, scope));
        return this.registerButton(btn);
    },
    
    /**
     * Override to destory the form.
     */
    destroy: function() {
        this.form.destroy();
        Ext.ux.FormBlind.superclass.destroy.call(this);
    }   
});