PDA

View Full Version : submit form for this form



parsbin
27 Feb 2011, 6:03 AM
Hi
i want create a submit button for this form without using ajax.(normal sending values with GET protocol)


how can do this?

fay
27 Feb 2011, 6:49 AM
From the FormPanel (http://dev.sencha.com/deploy/dev/docs/?class=Ext.form.FormPanel) docs:



By default, Ext Forms are submitted through Ajax, using Ext.form.Action (http://dev.sencha.com/deploy/dev/docs/output/Ext.form.Action.html). To enable normal browser submission of the BasicForm (http://dev.sencha.com/deploy/dev/docs/output/Ext.form.BasicForm.html) contained in this FormPanel, see the standardSubmit (http://dev.sencha.com/deploy/dev/docs/output/Ext.form.BasicForm.html#Ext.form.BasicForm-standardSubmit) option.

parsbin
28 Feb 2011, 12:10 AM
thanks
but i can`t solve this problem.
this is my design codes.



Ext.onReady(function(){
Ext.QuickTips.init();

// turn on validation errors beside the field globally
Ext.form.Field.prototype.msgTarget = 'side';

var store = new Ext.data.SimpleStore({
fields: ['abbr', 'state', 'nick'],
data : Ext.exampledata.states // from states.js
});

var company = new Ext.FormPanel({
frame:true,
url:'test.php',
defaultType: 'textfield',
items: [{ fieldLabel: 'Company Name',
name: 'name',
nameSpace : 'company',
labelSeparator : '',
width: 230,
allowBlank:false,
dynamic:true,
maxOccurs:5,
listeners : { 'maxoccurs' : {fn: function(field) {
Ext.example.msg('maxoccurs', 'Implement behaviour of maxoccurs');
}}
}
} ],
buttons: [{text: 'Save'},{text: 'Cancel'}]
});
var person = new Ext.FormPanel({
id:'panel',
frame:true,
defaultType: 'textfield',
items: [{dynamic : true,
maxOccurs:5,
xtype : 'fieldset',
title: 'مشخصات فردی',
id : 'fs',
nameSpace:'person',
autoHeight:true,
width: 300,
defaultType: 'textfield',
listeners : { 'maxoccurs' : {fn: function(fieldset) {
Ext.example.msg('maxoccurs', 'Implement behaviour of maxoccurs');
}}
},
items :[
{
fieldLabel: 'نام',
name: 'first',
dynamic:true,
maxOccurs:5,
listeners : { 'maxoccurs' : {fn: function(field) {
Ext.example.msg('maxoccurs', 'Implement behaviour of maxoccurs');
}}
},
width : 150
},
{
fieldLabel: 'Last Name',
name: 'last',
width : 150
}
]
},
{ fieldLabel: 'State',
name : 'state',
nameSpace : 'location',
labelStyle: 'width:75px;',
store: store,
displayField:'state',
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
emptyText:'Select a state...',
selectOnFocus:true,
xtype:'combo',
labelSeparator : '',
width: 230,
allowBlank:false,
dynamic:true,
maxOccurs:5,
listeners : { 'maxoccurs' : {fn: function(field) {
Ext.example.msg('maxoccurs', 'Implement behaviour of maxoccurs');
}}
}
},
{ fieldLabel: 'Birth date',
name: 'birthDate',
nameSpace : 'person',
allowBlank:false,
xtype:'datefield',
labelSeparator : '',
width: 230,
dynamic:true,
maxOccurs:5,
listeners : { 'maxoccurs' : {fn: function(field) {
Ext.example.msg('maxoccurs', 'Implement behaviour of maxoccurs');
}}
}
}
],
buttons: [{text: 'GetValues'
,type: 'submit'
,handler : function(b,e) {
var panel = Ext.getCmp('panel');
var location = panel.extract('location','field');
var fsperson = panel.extract('person','fieldset');
var fperson = panel.extract('person','field');
Ext.Msg.alert('Status', 'nameSpace location of field'+Ext.encode(location)+' nameSpace person of fieldset'+Ext.encode(fsperson)+' nameSpace person of field'+Ext.encode(fperson));
}
}
]
});
var tabs = new Ext.TabPanel({
width:450,
defaults:{autoHeight: true},
activeTab: 0,
items: [
{title:'شخص',id: 'person' ,items: [person]},
{title:'شرکت',id: 'company' ,items: [company]}
]

});

tabs.render(document.body);

//
// you can change the amount of clones on the fly
// fieldSet.clones(2);
// person.getForm().findField('state').clones(1);
// person.doLayout();

person.populate(Ext.decode('{"state":["Netherlands","Delaware"]}'),'location','field');
person.populate(Ext.decode('[{"first":["Adriaan","Cornelis"],"last":"Zaanen"},{"first":["Bill"],"last":"Joy"}]'),'person','fieldset');
person.populate(Ext.decode('{"birthDate":"03/12/2009"}'),'person','field');
company.populate(Ext.decode('{"name":["UCan","Informa"]}'),'company','field');
person.doLayout();
company.doLayout();

// you can retrieve the current set of clones
var curr = Ext.getCmp('fs').clones();
});

fay
28 Feb 2011, 1:10 AM
Where did you specify standardSubmit (http://dev.sencha.com/deploy/dev/docs/output/Ext.form.BasicForm.html#Ext.form.BasicForm-standardSubmit)? Take a look at the example in the link.

parsbin
28 Feb 2011, 1:54 AM
Solved! thanks


var submit = person.addButton({
text: 'Submit',
disabled:false,
handler: function(){
var panel = Ext.getCmp('panel');
var location = panel.extract('location','field');
var fsperson = panel.extract('person','fieldset');
var fperson = panel.extract('person','field');
person.getForm().submit({url:'tst.php?loc='+Ext.encode(fsperson), waitMsg:'Saving Data...', submitEmptyText: false});
}
});



but my new problem is how to spiliting that out put?
that out put is same to

[{\"first\":[\"Reza\",\"Ali\",\"Mohammad\"],\"last\":[\"Alipoor\",\"Imani\",\"Javadi\"]}]

i want fetch first and last names .