Accept Image In Filefield Extjs
I have a filefield componente in my application and I want to restrict it to only image files. I've found this question on stackoverflow: How to restrict file type using xtype file
Solution 1:
This is happening because when you submit form, it calls Ext.form.field.File#reset()
.
You should override reset() method like this, to keep you accept property:
{
xtype:'filefield',
reset: function () {
var me = this,
clear = me.clearOnSubmit;
if (me.rendered) {
me.button.reset(clear);
me.fileInputEl = me.button.fileInputEl;
me.fileInputEl.set({
accept: 'audio/*'
});
if (clear) {
me.inputEl.dom.value = '';
}
me.callParent();
}},
listeners:{
afterrender:function(cmp){
cmp.fileInputEl.set({
accept:'audio/*'
});
}
}
}
Post a Comment for "Accept Image In Filefield Extjs"