PDA

View Full Version : Error while form submitted



masih_muda
20 May 2012, 7:35 AM
Hi,

This is my first thread, Sorry i can only speak little in english.
I have problem with using form with upload file,

Here is my view code :


Ext.define ( 'PG.view.poi.formPOI', {
extend: 'Ext.window.Window',

alias: 'widget.windowPOI',

height: 150,
id: 'windowPOI',
width: 400,
title: 'Admin - POI',
layout: 'fit',
modal: true,
items: {


xtype: 'form',


frame: true,
waitMsgTarget: true,
url: site_url + 'poi/modify',
//standartSubmit: false,
fileUpload: true,


defaults: {


anchor: '100%',
msgTarget: 'side',
allowBlank: false,
msgTarget: 'side',
labelWidth: 50

},


items: [


{


xtype: 'container',
layout: 'column',
style: 'padding: 5px; border-bottom: 1px solid #AEABAB',
items: [


{


xtype: 'image',
id: 'imagePOI',
cls: 'd-icon',
align: 'left',
width: 40,
src: base_url + '/images/icons/no-image.png'


}, {


xtype: 'container',
width: 300,
style: 'margin-left: 15px',
items: [


{


xtype: 'hidden',
id: 'poiID',
name: 'id',


}, {


xtype: 'textfield',
name : 'name',
id: 'poiName',
allowBlank: false,
width: 290,
fieldLabel: 'Name',
anchor: '99%'

}, {


xtype: 'filefield',
name: 'icon',
fieldLabel: 'Icon',
emptyText: 'Select an image',
width: 280,
buttonText: '',
buttonConfig: {


iconCls: 'upload-icon'

}


}


]


}


]


}


],


buttons: [{


text: 'Save',
name: 'SaveButton',
scope: this,
action: 'formSubmit'


}]


}

});


and controller code:


Ext.define ( 'PG.controller.POIController', {
extend : 'Ext.app.Controller',


stores : ['StorePOI'],
models : ['POIModel'],
views : ['poi.formPOI'],

refs: [


{


ref: 'windowPOI',
selector: 'form'

},
{


ref: 'SaveButton',
selector: 'windowPOI button[action=formSubmit]'


}


],


init: function () {


console.log ( 'Initialized! This happens before the Application launch function is called' );
this.control ({


'windowPOI button[action=formSubmit]': {


click: this.POISubmit


}


});


},

POISubmit: function ( button ) {


var form = button.up ( 'form' ).getForm ();
if ( !form || !form.isValid () ) {

return;


}



form.submit ({


url: site_url + 'poi/modify/',
decode: false,
waitMsg: 'Saving...',
success: function ( fp, o ) {


alert ( 'Success', 'Processed file "' + o.result.file + '" on the server' );


}


});


}
});


when i submit this form, the following message displayed :


uncaught exception: You're trying to decode an invalid JSON String: Array ( [id] => 1012 [name] => Apartment ) Array ( [icon] => Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 ) )


I have tried for many times with difference code, but this message error always displayed in Firebug.
For your information, I'm using Firefox 12 and google chrome.

Is anyone can help?
Thanks Before

masih_muda
20 May 2012, 10:23 AM
Solved,
Just give a feedback in backend.

m.sureshkms
20 May 2012, 9:21 PM
Hi masih_muda

I (http://www.sencha.com/forum/member.php?436406-masih_muda) think your form has been submitted, but the Response return is not in valid json format.. your format should in key: value pair, Once again check your JSON format.

Thanks,
Suresh

masih_muda
23 May 2012, 9:45 PM
Hi m.sureshkms,

thanks for your respond, i have fixed the json format, and it's work.