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.

Validation message not allowing confirmation message

  1. BIGLIFE
    Member

    I am using the gf_validation_message function to change the main validation message. All is working except if I submit the form and it kicks back an error and thus the new message then when the info in question is corrected and the form is resubmitted the confirmation message does not appear and the error message remains. Any Ideas?

    Posted 13 years ago on Thursday September 8, 2011 | Permalink
  2. I'm not sure I completely follow, the description is a little confusing. Can you provide a link to the form and give me step by step instructions on how to replicate it so I can see what you are talking about?

    Posted 13 years ago on Thursday September 8, 2011 | Permalink
  3. BIGLIFE
    Member

    OK, here is what I've got so far:

    I am wanting to run this function to validate that the online donation goes through with my online payment processor and if not to display a custom error message:

    // Tie our validation function to the 'gform_validation' hook
    add_filter('gform_validation_9', 'validate_donation');
    function validate_donation($validation_result) {
    
    	// Make a call to donate.php validation function to validate the donation
    	$is_valid = process_payment();
    
    	// If the payment is valid we don't need to do anything
    	if($is_valid){
       		// Return the validation result
        	return $validation_result;
    		}
    	else{
    		// Fail the validation for the entire form
    		$validation_result['is_valid'] = false;
       		// Return the validation result
        	return $validation_result;
    		}
    }
    
    // This function runs the Donation script for eTapestry/SAGE
    function process_payment() {
        include("donate.php"); 	//this is the processing of the online donation
    }
    
    // This function changes the main validation message
    add_filter("gform_validation_message_9", "change_message", 10, 2);
    function change_message($message, $form){
    global $donate_error;
     	return '<div id="donate_error">' . "An error occurred while processing your submission.<br/>Please modify your information based on the error below and try again.<br/><br/>" .  '<span>' . "Error: {$donate_error}" . '</span>' . '</div>';
    }

    If the payment info goes through then I would like to show the confirmation message assigned by the form notifications and if not then I want the custom message to be displayed via the function change_message function. I have used some of the code from your sample code found here (http://pastie.org/1769048) . What kind or response is the $is_valid variable looking for from the process_payment function? Is it looking for true/false? I currently am getting an error message no matter if the payment is valid or not.....its throwing an error either way. Any advise?

    Posted 13 years ago on Monday September 12, 2011 | Permalink
  4. Do you have an example of what donate.php returns?

    $is_valid will be true or false in the code example http://pastie.org/1769048 (see lines 140 and 143 which are returned by the function.)

    Posted 13 years ago on Tuesday September 13, 2011 | Permalink