PDA

View Full Version : [SOLVED] Forms and Ext Direct



michael.piecko
15 Jun 2009, 2:19 AM
Hi all.

After almost finishing my first Ext app with Ext 2, i make my first steps towards Ext 3 because of the great new Ext Direct feature. There are a lot of REST examples around with grids and forms, but i didn't find any example with a simple no-record form. Just imagine a login form.

In the last blog there was an example how to setup a form to use Ext Direct http://extjs.com/blog/2009/06/03/ext-js-30-rc2-release-stable-robust-and-enhanced (last paragraph)

But this paragraph ends at the most interesting part: how to submit this form using a button and Ext Direct? I didn't succeed with myFormPanel.getForm().submit()? Is this still the way to do it?

Thans in advance for any hint or example.

Michael

aconran
15 Jun 2009, 6:01 AM
Michael -

Provide your form an api configuration with a submit action like so:



api: {
submit: MyFormAction.submit
}


Ext will automatically recognize that you are intending to submit your form via Ext.Direct. Now when you do:


myFormPnl.getForm().submit();


It will automatically submit to your MyFormAction.submit on the server-side. This will be a standard form post and therefore you will need to specify the formHandler attribute in the Ext.Direct stack.

michael.piecko
15 Jun 2009, 6:15 AM
aconran, i feel ashamed.

This works perfectly. My api setting was in the Ext.Window config containing the form, not in the Ext.form.FormPanel, where it belongs to. Damn ...

Michael

aconran
15 Jun 2009, 6:17 AM
No problem; Glad you got it up and running! :D

jai1485
22 Jul 2010, 11:13 PM
My question may be silly.
Please help me out of this issue.
I am using a form with direct api and trying to insert records in to the db. But form values are not submitting to the server side.
My Code:
formadd= new Ext.form.FormPanel({
// configs for FormPanel
title: ‘Add record’,
border: false,
padding: 10,
buttons:[{
text: 'Submit',
handler: function(){
formadd.getForm().submit({
params: {
foo: 'bar',
uid: 34
}
});
}
}],
defaultType: ‘textfield’,
items: [{
fieldLabel: 'Name',
name: 'name'
},{
fieldLabel: 'Email',
msgTarget: 'side',
name: 'logo_url'
}],
api: {
// The server-side method to call for load() requests
load: Vendor.read,
// The server-side must mark the submit handler as a ‘formHandler’
submit: Vendor.save
},
// specify the order for the passed params
paramOrder: ['uid', 'foo']
});
Please help me!!!!!!! :-/

Andrew Peacock
26 Jul 2010, 3:47 AM
See my reply in the other thread you posted to.
Andy