I am using Ext Js 3.4. I run into a problem when using myform.getForm.getValues()
emptytext
is also sent in the request.
Below is the code snippets
myForm = new Ext.FormPanel({
id: 'myForm ',
items: [
{
region:'center',
border:false,
items:[center_one]
},{
region:'west',
border:false,
items :[west_one]
},{
region:'east',
border:false,
items :[east_one]
},{
region:'south',
layout:'table',
iborder:false,
items: [south_one]
}
]
});
var west_one= new Ext.form.FieldSet({
width: 282,
height:250,
layout: 'table',
items: [{
id: 'form1',
layout: 'form',
items: [field1]
},{
id: 'form2',
layout: 'form',
items: [field2]
}]
});
var field1 = new Ext.form.ComboBox({
fieldLabel: 'Field',
width: 150,
name: 'field1',
cls: 'fields field1',
id: 'field1',
store: field1Store,
displayField: 'name',
valueField: 'name',
mode: 'local',
emptyText: 'Select Field1', // This value gets submiited when no value is selected
selectOnFocus: true,
triggerAction: 'all',
forceSelection : true,
editable:true,
typeAhead:true,
});
And this is how I submit:
Ext.Ajax.request({
url: 'forms.do?submit',
method: 'POST',
params: myForm.getForm().getValues(),
success: function(response, option){
},
failure: function(){
}
});
You will Need to add this config in submitform xtype :
submitEmptyText: false
By defalut submitEmptyText is set to true. Check it on Online Documentation HERE.
EDIT:try the following code instead of Ext.ajax:
var myForm = Ext.getCmp('myForm').getForm();
myForm.submit({
url : 'forms.do?submit',
method : 'POST',
fileUpload : true,
submitEmptyText : false,
// waitMsg : 'Saving data',
success : function(form, action) {}
});
If you just want to get the values without emptytext
(for example to submit them using Ext.Ajax
as in your question), use myForm.getForm().getFieldValues()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With