PDA

View Full Version : build and submit form in without render.



paulypaul
24 Sep 2009, 6:31 AM
Hi,

I have created a simple form.

I would like to build this form and submit it in the background - without rendering it to the screen. I do not want this to happen asynchronously.

I may have flawed logic here and not actually need a form. The below code was my stab at trying a simple example. The error I got was : this.form.el is undefined, which looks like it is to do with the FormPanel not being rendered yet.



var simple = new Ext.form.FormPanel({
labelWidth: 75, // label settings here cascade unless overridden
url:'save-form.php'
});
simple.add(
new Ext.form.TextField({
fieldLabel: 'First Name',
name: 'first',
width:175,
allowBlank:false
}),

new Ext.form.TextField({
fieldLabel: 'Last Name',
name: 'last',
width:175
})

);

simple.getForm().submit();

hendricd
24 Sep 2009, 6:35 AM
That does seem a bit heavy for a simple POST:



Ext.Ajax.request({
method : 'POST',
url : '??',
params : {
first : 'Pauly',
last : 'Paul'
},
success : function(){}
});

paulypaul
24 Sep 2009, 6:45 AM
Look a lot better but I didn't want it to happen asynchronously, I actually want to go to the form submission page - I know strange in these days.

hendricd
24 Sep 2009, 6:47 AM
Ah, use the ext-basex adapter extension (my sig below) and:



Ext.Ajax.request({
method : 'POST',
url : '??',
async : false,
params : {
first : 'Pauly',
last : 'Paul'
},
success : function(){}
});

paulypaul
24 Sep 2009, 7:07 AM
Fantastic!

Cheers Doug Hendricks I will implement that now.