Hello every one i have a really big problem, my company has a subscription with gravity forms, but since the last year, our multi-step form gave up on working properly.
The strange is, that the next button submits the form and makes us jump to the last page, but the previous button works like a charm.
Can you help us?
I will not be able to give you access because of the EU RGPD, but i 'll leave the link of a dummy site we have so you can inspect at your will.
I have already disabled and enabled the plugins and its not any of them, but the problem still subsists.
I would appreciate your help in sharing why can it happen, the previous button works, and the next doesn’t, when they have the same jquery structure and all.
Hello @sacom , i don’t know if you or @chrishajer can help but i have discovered what is wrong and believe it or not it wasn’t the theme it self, but it was theme related.
i Have a child theme, and the multistep i use, in the last step user has to input name, email, and phone number.
the piece of code present in the child theme php that validates thos fields is the following:
add_filter( ‘gform_validation’, ‘custom_validation’ );
function custom_validation( $validation_result ) {
$form = $validation_result[‘form’];
//input_4 é sempre o do telemovel, input_5 o email
if ( strlen(rgpost( ‘input_3’ )) !== 9 ) {//verificação para saber se o input tem 9 algarismos
$validation_result[‘is_valid’] = false;
foreach( $form[‘fields’] as &$field ) {
if ( $field->id == ‘3’ ) {
$field->failed_validation = true;
$field->validation_message = ‘O número de telemóvel tem de ter 9 algarismos!’;
break;
}
}
}
elseif (rgpost( 'input_3' )[0]!=9 && rgpost( 'input_3' )[0]!=2){//verificação para saber se o input começa por "2" ou "9"
$validation_result['is_valid'] = false;
foreach( $form['fields'] as &$field ) {
if ( $field->id == '3' ) {
$field->failed_validation = true;
$field->validation_message = 'O número de telemóvel tem de começar por 2 ou 9';
break;
}
}
}
//Validação para deixar o email apenas ter 50 carateres
if ( strlen(rgpost( ‘input_4’ )) >50 ) {
$validation_result[‘is_valid’] = false;
foreach( $form[‘fields’] as &$field ) {
if ( $field->id == ‘4’ ) {
$field->failed_validation = true;
$field->validation_message = ‘Tamanho do email excedido, máximo de 50 carateres!’;
break;
}
}
}
//Assign modified $form object back to the validation result
$validation_result[‘form’] = $form;
return $validation_result;
}
Can you help me inspect why they are wrong?
if i comment this code the form works like a charm(without the much needed validation, but the error is in here, somewhere, but by me i can’t find it).
so i found out that this hook ‘gform_validation’ doesn’t work in multi step forms, and we have to be more specific to validate the field we want in the multi step form using gform_field_validation hook, and we can manage to make it work