In 4.1.1 setVisible(false) and hide() work for me, though I'm not seeing the field when doing a show() or setVisible(). But, the showing is not working for me when working with a file field or a textfield (within a form).
Not any better for me in 4.2 beta.
Thought formpanel.updateLayout() or suspend/resumeLayouts might help, but no dice.
For what it's worth here's my test code.
Code:
Ext.create('Ext.form.Panel', {
renderTo: Ext.getBody(),
width: 500,
frame: true,
title: 'File Upload Form',
bodyPadding: '10 10 0',
defaults: {
anchor: '100%',
allowBlank: false,
msgTarget: 'side',
labelWidth: 50
},
items: [{
xtype: 'textfield',
fieldLabel: 'Name'
},{
xtype: 'filefield',
id: 'form-file',
emptyText: 'Select an image',
fieldLabel: 'Photo',
name: 'photo-path',
buttonText: 'upload',
}],
buttons: [{
text: 'Save',
handler: function(){
var form = this.up('form').getForm();
if(form.isValid()){
form.submit({
url: 'file-upload.php',
waitMsg: 'Uploading your photo...',
success: function(fp, o) {
msg('Success', 'Processed file "' + o.result.file + '" on the server');
}
});
}
}
},{
text: 'Reset',
handler: function() {
this.up('form').getForm().reset();
}
}, {
text: 'Hide',
enableToggle: true,
handler: function (btn, pressed) {
var ff = btn.up('form').down('filefield');
pressed ? ff.hide() : ff.show();
}
}]
});