PDA

View Full Version : [FIXED-EXTJSIV-2527]Error when trying to call reset on a filefield NOT rendered



kerryquinn
3 Jun 2011, 1:52 PM
If you have a form broken up by a fieldset and, you call the 'reset()' method on that Form when the following two conditions are true:

(b) There is a filefield defined within a fieldset AND
(b) That filefield has yet to be rendered because the fieldset was configured with 'collapsed:true'

An error is thrown around line 102603 of ext-all-debug-w-comments.js (rev 4.0.1). You can see the reset function trying to remove the fileInputEl with 'remove()' call. However, that element does not yet exist until the fieldset containing the field has been expanded at least once.


reset : function(){
this.fileInputEl.remove();
this.createFileInput();
this.callParent();
}


This simple hack appears to have resolved this for me:


reset : function(){
if(!typeof this.fileInputEl == 'undefined'){
this.fileInputEl.remove();
this.createFileInput();
this.callParent();
}
}

But it seems to be a bug to me. The following is a sample form panel that will exhibit this behavior when its form is 'reset()'.



Ext.create('Ext.form.Panel', {
id:'leftUserFormPanel',
title: 'Sample Panel',
autoScroll: true,
closable: false,
padding: '0',
fileUpload: true,
pollForChanges: true,
dockedItems: [{
dock: 'bottom',
xtype: 'toolbar',
itemId: 'addUserButtonToolbar',
items: [
{
text: 'Cancel',
handler: resetSampleForm,
formBind:false,
hidden: false,
itemId: 'resetButton'
},
{
text: 'Add',
handler: doAdd,
formBind:true,
itemId: 'addButton'
}
]
}],
items: [
{
xtype:'fieldset',
checkboxToggle:false,
title: 'Basic Details',
defaultType: 'textfield',
collapsed: false,
items :[

{
id: 'first',
fieldLabel: 'First Name',
name: 'first',
allowBlank:false
},{
id: 'last',
fieldLabel: 'Last Name',
name: 'last',
allowBlank:false
}
]
},
{
id: 'additionalCheckbox',
xtype:'fieldset',
checkboxToggle:true,
title: 'Additional Details',
defaultType: 'textfield',
collapsed: true,
items :[
{
xtype: 'filefield',
id: 'photo',
fieldLabel: 'Photo',
name: 'photo',
buttonText: 'Browse...'
}
]
}
]
}

evant
14 Jun 2011, 11:03 PM
Thanks for the report, I've added an extra check for the field to be rendered before it tries to interact with the DOM.