Hi all,
When the form is submitted, the filefield is reset.
It look OK when I submit the form.
The value that I see in the field is not reset to empty.
However, when I submit the form again without re-choose file, the data that be sent to the server is null.
File upload field is reset when submit form
I am using ExtJS version 4.1.1.
I try to create upload file form using filefield as follow:
Code:
{
xtype: 'filefield',
itemId : 'my-file',
name: 'my file',
emptyText : 'No file chosen',
fieldLabel: 'Upload File',
submitValue: true,
allowBlank : false,
buttonText: 'Browse',
listeners: {
change: function(fld, value) {
var newValue = value.replace(/C:\\fakepath\\/g, '');
fld.setRawValue(newValue);
}
}
}
When the form is submitted, the filefield is reset.
As I see in
http://ift.tt/1rQSxSM
I try to override the filefield to :
Code:
Ext.override(Ext.form.field.File, {
extractFileInput: function() {
var me = this,
fileInput = me.fileInputEl.dom,
clone = fileInput.cloneNode(true);
fileInput.parentNode.replaceChild(clone, fileInput);
me.fileInputEl = Ext.get(clone);
me.fileInputEl.on({
scope: me,
change: me.onFileChange
});
return fileInput;
}
It look OK when I submit the form.
The value that I see in the field is not reset to empty.
However, when I submit the form again without re-choose file, the data that be sent to the server is null.
The data that be sent to the server should be retained.
How can I fix this problem?
Thanks in advance.
earist.
File upload field is reset when submit form
Aucun commentaire:
Enregistrer un commentaire