1. #1
    Ext User
    Join Date
    Aug 2007
    Posts
    23
    Vote Rating
    0
    ssa962 is on a distinguished road

      0  

    Default Config object problem

    Config object problem


    I have created a config object for my FormPanel as shown below-

    Code:
    var myFormConfig = {
    	bodyStyle:'padding:25px 0px 0px 10px',
    	url: 'saveform.php',
    	items: [{
    		layout: 'form',
    		border: false,
    		defaultType: 'textfield',
    		items: [{
    			fieldLabel: 'Name',
    			name: 'name',
    			allowBlank: false,
    			anchor:'80%'
    		}]
    	}]
    };
    And now I use it to create a FormPanel -

    Code:
    var myForm1 = new Ext.FormPanel(myFormConfig);
    Everything is fine so far until I try to create another FormPanel with a "save" button, like the following -

    Code:
    var myForm2 = new Ext.FormPanel(
    	{
    	myFormConfig,
    	buttons: [{
    		text: 'Save',
    	}]
    	}
    );
    Maybe this is not the way to add buttons to the form. I am just wondering if there is any way to do this. I don't want both the forms to have save button, the second form should have the save button.

    Any help is highly appreciated.

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    56
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    That's just not javascript.

    A configuration object must be an object.

    An object is a list of name: value pairs between "{" and "}".

  3. #3
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    56
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Read up about Ext.apply

  4. #4
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    6
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    or look at using a factory (discussed in the wiki).

Thread Participants: 2