Results 1 to 5 of 5

Thread: send param to php in form

  1. #1
    Sencha User
    Join Date
    Sep 2011
    Location
    Sallanches, France
    Posts
    371
    Answers
    16
    Vote Rating
    1
      0  

    Default send param to php in form

    Hello,

    I have a list and in the detailPanel, i have a form. when the itemTap of the list coming, i build the form and send the email of the list store for the concerning item to the form.
    I would like when i treat the form in php, get the email from the build form function...
    Is it possible ?

    I tried:
    Code:
    addContactForm: function(email) {
    		var emailitem = email;
    		var contactFormPanel;
    		var formBase = {
    			scroll: 'vertical',
    			url: App.config.host + App.config.PhpPath + 'sendEmail.php',
    			standardSubmit : false,
    			items: [
    				{
    					xtype: 'fieldset',
    					items: [
    					{
    						xtype: 'textfield',
    						name: 'name',
    						label: App.config._ContactLabelName,
    					},
                                            ........................
    					]
    				}
    			],
    			dockedItems: [
    				{
    					xtype: 'toolbar',
    					dock: 'top',
    					items: [
                                                    .........................
    						{
    							text: App.config._ContactButtonSend,
    							ui: 'confirm',
    							handler: function() {
    								var model = ...
    									contactFormPanel.submit({
    										params: {
    											emailToSend: emailitem
    										},
    										success: function (frm, res) {
    											Ext.Msg.alert("", res.messageSend, Ext.emptyFn);
    											contactFormPanel.reset();
    										},
    									});
    								} 
    							}
    						}
    					]
    				}
    			]
    		};
    		contactFormPanel = new Ext.form.FormPanel(formBase);
    		return contactFormPanel;
    	},
    When i do an alert of: var emailitem = email; that's good, i have the good item email.

    But with:
    Code:
    										params: {											emailToSend: emailitem
    },
    The first time i'm coming in the form, the email is good, but when i come back to the list and choose another item and go to the contact form, the email in param keep the first email .... it doesn't take the new email variable ...

    this is a part of the php:
    PHP Code:
        $emailToSend $_POST['emailToSend'];    $name $_POST['name'];        $response = array('success' => true'messageSend' => 'send to: '.$emailToSend);    echo json_encode($response); 
    Email to send keep the same value that the first Item.

    Can you help me please?

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    In your button handler the variable emailitem is correctly updated each time?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Sep 2011
    Location
    Sallanches, France
    Posts
    371
    Answers
    16
    Vote Rating
    1
      0  

    Default

    No, and this is the problem ...
    At the beginning of the function, i have the good email,
    but when i'm coming in the validate handler, the email stay to the first Item ...

    In the console:
    Capture d’écran 2011-11-30 à 15.36.38.jpg

    A part of the code for the form:
    Code:
    	addContactForm: function(email) {
    		var emailitem = email;
    		console.log("START OF addContactForm:" + emailitem);
    		var contactFormPanel;
    		var formBase = {
    			url: App.config.host + App.config.PhpPath + App.config._FileEmailForm,
    			standardSubmit : false,
    			items: [ ...... EACH TEXTFIELD ],
    			dockedItems: [
    				{
    					xtype: 'toolbar', dock: 'top',
    					items: [
    						{
    							handler: function() {
    								console.log("START OF handler:" + emailitem);
                                                                    .... CHECK ERRORS
    								if(errors.isValid()) {
    									console.log("AFTER CHECK isValid:" + emailitem);
    									contactFormPanel.submit({
    										params: { emailToSend: emailitem },
    									});
    								} else {
    									........ 
    								}}}]}]
    		};
    		contactFormPanel = new Ext.form.FormPanel(formBase);
    		return contactFormPanel;
    	},
    I don't know why the variable loses the value in the handler ...
    Thanks by advance

  4. #4
    Sencha User
    Join Date
    Sep 2011
    Location
    Sallanches, France
    Posts
    371
    Answers
    16
    Vote Rating
    1
      0  

    Default

    up

  5. #5
    Sencha User
    Join Date
    Sep 2011
    Location
    Sallanches, France
    Posts
    371
    Answers
    16
    Vote Rating
    1
      0  

    Default

    no idea ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •