View Full Version : ExtJS form Submit

16 Jul 2012, 8:43 AM

I have a ExtJS form with fields like below

Name Field ( Note : Multiple comma separated names are allowed )
Age Field
Email Field
I want to submit this form values to the server side and notify the about the same (success or failure) to the email address provided in the email field i.e 3rd form field.

Since there could be multiple names in the name field, I don't want to get multiple response for this single form submission.

I don't want to send multiple form submission Ajax request.
I want to submit the multiple names in a single Ext.Ajax.request() and then send a SINGLE notification to the email address value.

How to achieve this ? How to correctly apply Ext.JSON.encode correctly ?

var values = Ext.getCmp('myForm').getValues();

method : 'POST',
url : ' ../../save.php',
params: Ext.JSON.encode(values),// How to encode multiple name values here?
success: function(response) {
Ext.Msg.alert('Data submitted to all people');
failure : function(response) {
Ext.Msg.alert('Error while submitting data to all people');


16 Jul 2012, 8:59 AM
Ext.form.Panel has a built-in submit mechanism. Why not just use that? This will send discreet request parameters like name, age, and email. If should be a relatively simple matter to then parse the email request parameter using a comma as the delimiter.

16 Jul 2012, 9:25 AM
Using form.submit() or Ext.Ajax.request() is not my question.


Name Field : Tom, Jerry, Mike
Email Field : abc@gmail.com

I want to pass all the names from the name field (i.e Tom, Jerry and Mike) in a single form submit Ajax request. I don't want to send multiple request for multiple names.

I want a single response to be generated to email address of 'abc@gmail.com'

16 Jul 2012, 9:48 AM
If you have a single form, you will get a single submit.

If a field has multiple names, then it will still be 1 string. You simple parse that field at the server level and generate a email for each and then send a single response back to the client.


16 Jul 2012, 9:48 AM
I believe by default it should be a string separated by comma.

If it's not a string and instead an array, you can do this:

values.name = value.join(',');

16 Jul 2012, 10:46 AM
@Scott : Thank you for your reply.

Let me clarify my question again.

I have the above form fields already mentioned. When I click some submit button, I want to send an email notification to all those people at their respective email ids and then get back a single notification to abc@gmail.com that form data was successfully submitted to all those people individually at their email id.

For the above problem statement, I need to send all the names in a single request.
I am aware of sending one single value for textfield ( i.e here name field), but how to do it for multiple names which may be comma separated ?

Is it achievable with your solution ?

16 Jul 2012, 12:34 PM
Yes .. this is like a distribution list ... you send 1 record to the server, the server would parse the field names (field id for each should be sent as param) and then send the emails and send a single record back for success/fail.

The key is to send the id's to ensure that you get the right "John Smith" and to have the server process all of the records and send the emails.