PDA

View Full Version : [Solved] Forms, Fieldsets and Buttons



Lloyd K
7 Feb 2008, 4:45 AM
I currently have the following dialog/form:

http://www.lloydkinsella.net/forumbin/0024.png

What I want to do is add a "Set" button to the fieldset underneath the edit boxes only I can't figure how to do this, does anyone have any ideas?

The code to generate the form is:



// Create security form
this.securityForm = new Ext.form.Form({
labelAlign: "left",
labelWidth: 150
});

// Create security form layout
this.securityForm.fieldset({
id: "gbxPassword",
legend: "Password"
},
new Ext.form.TextField({
fieldLabel: "Current Password",
name: "userprefs_currentpassword",
inputType: "password",
width: 400
}),
new Ext.form.TextField({
fieldLabel: "New Password",
name: "userprefs_newpassword",
inputType: "password",
width: 400
}),
new Ext.form.TextField({
fieldLabel: "Confirm New Password",
name: "userprefs_confirmpassword",
inputType: "password",
width: 400
})
);
this.securityForm.end();

// Render security form to dialog
this.securityForm.render(securityFormId);

sixtoedsloth
7 Feb 2008, 4:59 AM
add a buttons component to your fieldset


buttons: [
{text: 'Set',listeners: ....},
{text: 'Cancel',listeners: ....}
]

fay
7 Feb 2008, 5:02 AM
The following - which should work for 1.1 ;) - is based on 'Change Photo' in the Dynamic Forms (http://extjs.com/deploy/ext/examples/form/dynamic.html) example:


this.securityForm.fieldset({
id: "gbxPassword",
legend: "Password"
},
// ...
this.securityForm.end();

this.securityForm.render(securityFormId);

var pwd = Ext.get('gbxPassword');
var ctnSet = pwd.createChild({tag:'center', cn: {tag:'div'}});

new Ext.Button(ctnSet, {
text: 'Set' // add handler, etc.
});

//Note: Fairly sure, you can leave out the ctnSet and just pass pwd to Ext.Button as well.

Lloyd K
7 Feb 2008, 7:18 AM
Thanks Fay that did exactly what I needed, I tried the photo thing but must have cocked it up :S