View Full Version : [newbie] FormPanel submit format

9 Aug 2009, 2:51 AM
I'm new and treading the waters with ExtJS - please bear with me :)

When I do a FormPanel submit - what is the format of the submission? is it JSON where all the fields in the FormPanel are the key/values in that JSON Object. My confusion is because of the following code - available from the ExtJS website - which seem to explicitly insert the required params in the the JSON? object. In fact, all of the fields are explicitly declared as global vars - which seem to be odd to me.

function saveThePresident(oGrid_event){
waitMsg: 'Please wait...',
url: 'database.php',
params: {
IDpresident: oGrid_event.record.data.IDpresident,
FirstName: oGrid_event.record.data.FirstName,
LastName: oGrid_event.record.data.LastName,
PartyName: oGrid_event.record.data.PartyName,
TookOffice: oGrid_event.record.data.TookOffice.format('Y-m-d'),
LeftOffice: oGrid_event.record.data.LeftOffice.format('Y-m-d'),
Income: oGrid_event.record.data.Income
success: function(response){
var result=eval(response.responseText);
case 1:
Ext.MessageBox.alert('Uh uh...','We couldn\'t save him...');
failure: function(response){
var result=response.responseText;
Ext.MessageBox.alert('error','could not connect to the database. retry later');

9 Aug 2009, 3:30 AM
It's submitted in perfectly normal HTTP form submission format.

The response must be JSON as described i nthe API docs.

9 Aug 2009, 3:31 AM
errrr, what global variables?

That's code that's doing a "manual" submission of a Record from a Store using Ajax directly.

To submit a form just use the submit method of the form.

9 Aug 2009, 3:52 AM
FormField names and their values are submitted which we can get using standard getParameter methods? But do we have to explicitly set the parameters as in the OP code? Or all fields contained within the FormPanel be submitted on a formPanel.submit()?

The global vars part in not in the OP code. Sorry.

9 Aug 2009, 3:54 AM
Try it!

Docs with example code: http://extjs.com/deploy/dev/docs/?class=Ext.form.BasicForm&member=submit