PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

gform_pre_submission accessing field values

  1. I have a hook here which works great (it looks for a field with the parameter name zip, and sets a hidden field based on the zip value):

    [php]
    add_action("gform_pre_submission", "set_email_notification_flag", 10, 2);
    
    function set_email_notification_flag($form){
    
    	//search for zip label and notification flag
    	$formfieldzip="";
    	$formfieldnotificationflag="";
    	foreach($form['fields'] as $k=>$v)
    	{
    		if($form['fields'][$k]['inputName']== "zipcode") $formfieldzip= "input_". $form['fields'][$k]['id'];
    		if($form['fields'][$k]['inputName']== "emailnotification") $formfieldnotificationflag= "input_". $form['fields'][$k]['id'];
    	}
    
        if ( ($formfieldzip!="")&&($formfieldnotificationflag!="")) {
    				$zipcode = $_POST[$formfieldzip];
    				$_POST[$formfieldnotificationflag]=zipcodearea($zipcode);
    	}
    }

    Now I have another hook for a specific form. This time I am trying to access the zipcode field of the address type advanced field.

    [php]
    add_action("gform_pre_submission_14", "set_email_notification_flag_14", 10, 2);
    //specific email notification form 14
    function set_email_notification_flag_14($form){
    	$formfieldzip="input_19.5";
    	$formfieldnotificationflag="input_25";
       	$zipcode = $_POST[$formfieldzip];
    	$_POST[$formfieldnotificationflag]=zipcodearea($zipcode);			
    
    }

    I find that I cannot access the zipcode value (the variable is empty). The same holds for all the sub fields of any of the advanced field types. I cannot lay a finger on what I am doing wrong. Thanks.

    Posted 5 years ago on Monday March 18, 2013 | Permalink
  2. I believe this input_19.5 should be input_19_5. Please dump the $_POST in your pre_submission filter and take a look at the exact format of the inputs. But input_19.5 looks incorrect to me, right off the bat.

    Posted 5 years ago on Tuesday March 19, 2013 | Permalink
  3. Thanks! Should have figured that one!

    Posted 5 years ago on Tuesday March 19, 2013 | Permalink
  4. Glad that was it. Take care.

    Posted 5 years ago on Thursday March 21, 2013 | Permalink

This topic has been resolved and has been closed to new replies.