Multi-page form validation for multiple cssclass [RESOLVED]

This is on a multi-page form. validating yes & no questions. It is jumping forward & breaking the flow of the form, how can I check if we are on the current page:

//check if binary field is required specific value
foreach ( $form['fields'] as $field ) {
	if ( 'gf_require_yes' == $field->cssClass  ) {
		
		if ( 'yes' != strtolower( $_POST[ 'input_'.$field->id ] )){  
				$field->failed_validation = true;
				$field->validation_message = 'To submit a successful application, you must answer Yes to this question';
				$validation_result['is_valid'] = false;
		}
	}
	if ( 'gf_require_no' == $field->cssClass  ) {
		if ( 'no' != strtolower( $_POST[ 'input_'.$field->id ] )){
				$field->failed_validation = true;
				$field->validation_message = 'To submit a successful application, you must answer No to this question';
				$validation_result['is_valid'] = false;
		}
	}
}

What filter are you using? I do not see that in your code. Is it gform_validation or gform_field_validation?

gform_field_validation has the $form object as one of the arguments, so you can do this in your code:

$current_page = GFFormDisplay::get_current_page( $form['id'] );

For gform_validation, you have to take an additional step, but from your code it looks like you are probably using gform_field_validation.

Thanks for your help. This is resolved now.

1 Like
© 2008 - 2019. Gravity Forms is a project by Rocketgenius Inc.