Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

emptyText is submitted with the form

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(){

                }
            });
like image 296
hop Avatar asked Feb 03 '12 10:02

hop


2 Answers

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) {}
});
like image 182
Mehdi Fanai Avatar answered Sep 20 '22 17:09

Mehdi Fanai


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().

like image 20
ᄂ ᄀ Avatar answered Sep 17 '22 17:09

ᄂ ᄀ