1. Add a function to submit the form:
var submitForm = function(){
formPanel.getForm().submit({
url: 'submit.php'
});
};
2. Add a button to the form that calls the submitForm function:
var formPanel = Ext.create('Ext.form.Panel', {
...
buttons: [{
text: 'Submit Form',
handler: submitForm
}],
items: [
...
]
});
Submitting a form from a Model instance
1. Extend the Model with a proxy and load the data into the form:
Ext.define('Request', {
extend: 'Ext.data.Model',
fields: ['FirstName', 'LastName', 'EmailAddress',
'TelNumberCode', 'TelNumber', 'RequestDetails', 'RequestType'],
proxy: {
type: 'ajax',
api: {
create: 'addTicketRequest.php',
update: 'updateTicketRequest.php'
},
reader: {
type: 'json'
}
}
});
var requestModel = Ext.create('Request', {
FirstName: 'Joe',
LastName: 'Bloggs',
EmailAddress: 'info@swarmonline.com'
});
formPanel.getForm().loadRecord(requestModel);
2. Change the submitForm function to get the Model instance, update the record with
the form data, and save the record to the server:
var submitForm = function(){
var record = formPanel.getForm().getRecord();
formPanel.getForm().updateRecord(record);
record.save();
};
댓글 없음:
댓글 쓰기