PDA

View Full Version : multipart/form-data saving problem



Saint Father
7 Dec 2011, 3:51 AM
i use form.Panel with htmleditor item and filefield item ..
when i try to save, the content of the htmleditor cut after first quotes;
when i remove a filefield item, the form (application/x-www-form-urlencoded) send full content from htmleditor without cutting;
please help me:
what could be the problem and how can I fix it?

form.Panel:

var newsForm = Ext.create('Ext.form.Panel', {
title: 'General info',
width: 800,
frame: true,
border: false,
bodyStyle: 'padding: 5px;',
items: [

{ xtype: 'hidden', name: 'id' },
{ xtype: 'filefield', fieldLabel: 'Preview', name: 'filename' },
{ xtype: 'htmleditor',


name: 'full_content',

height: 300,
width: 780,
fieldLabel: 'News content' }

],

buttons: [


{ text: 'Close',
handler: function() { editNewsWindow.close();}
},
{ text: 'Save',
formBind: true,
disabled: true,
handler: function() { saveNewsItem(); }
},
{ text: 'Save and close',
formBind: true,
disabled: true,
handler: function() { saveNewsItem(true); }
}

]
});

save button handler:

var saveNewsItem = function(close) {


if (newsForm.getForm().isValid()) {


newsForm.getForm().submit({


url: '/admin/news/save/',
success: function(thisform, action) {


if (action.result.success) {


if (close) { editNewsWindow.close(); }
newsStore.load();
var newsRecord = action.result.data; newsForm.getForm().setValues(newsRecord);
if (newsRecord.filename != 'undefined') {


newsImage.setSrc('/img/1/' + newsRecord.filename + '?' + Math.random());


}
newsId = newsRecord.id;
tabpanel.contentId = newsRecord.id;
tabpanel.items.each(function(tab) { tab.enable(); }); newsForm.getForm().setValues(newsRecord); newsForm.getForm().findField('slug').disable();


}


},
failure: function(form, action) { }


});


}

}

Saint Father
19 Dec 2011, 11:10 PM
or may be it's so simple question? where can i read about that? :-?

skirtle
19 Dec 2011, 11:46 PM
What do you mean by 'cut after first quotes'?

How are you ascertaining that the value is cut? I'd advise checking the request in Firebug or the Chrome Developer Tools to check what value got sent.

Saint Father
20 Dec 2011, 12:09 AM
i write in htmleditor "bla-bla", aline to right side ... in source mode i see <div style="text-align:right;">bla-bla</div> .. i switch htmleditor to WYSIWYG mode and press Save button ...

my php script receives the "full_content" param with <div style=" only .. ( 'cut after first quotes')
.. with 'filefield' the form sends by POST and
when i look to FireBug, i see the same <div style=" in "full_content" param value.
.. without 'filefield' the form sends by GET "full_content" is really full

I know, seems the magic .. but what can i check else?

skirtle
20 Dec 2011, 12:56 AM
First thing I'd try is testing in different browsers. The HtmlEditor is very browser-dependent and it'd be worth knowing exactly which browsers have this problem.

Next I'd try putting a breakpoint at the start of the method buildForm in Ext.form.action.Submit. Step through and try to understand where it goes wrong. My first thought is that it's an escaping issue on the hidden input's value attribute (which is " terminated) but from looking at the code it seems correct to me.