[Forminator] Issues with custom error message and submission behaviour

After the recent update of Forminator, I noticed two issues. Can you help me with that? I would appreciate it if there was a quick fix for those issues.

  • Adam Czajczyk
    • Support Gorilla

    Hello F404

    I hope you’re well today and thank you for reaching out to us!

    The error message isn’t actually a bug. It’s related to the case where the field is set as required but nothing was entered but not the data validation itself.

    As for the “same/new tab” issue. That seems to be a bug and we’ve already reported it to our developers so they could take care of it. They’ll work on it and I believe that the fix would be released as a part of one of upcoming updates so please keep the plugin up to date. In case we also had some sort of a patch/workaround or some additional information on this – we’ll post them here too.

    Best regards,

    Adam

  • F404
    • Flash Drive

    Hello

    The error message isn’t actually a bug. It’s related to the case where the field is set as required but nothing was entered but not the data validation itself.

    But it not showing costume error massage.

    Also it is Impossible by WPML

  • Sohag Ronjon Dey
    • Support

    Hello F404,

    Thanks for the reply and we hope you are doing well. :slight_smile:

    Sorry for any confusion.

    The error message isn't actually a bug. It's related to the case where the field is set as required but nothing was entered but not the data validation itself.

    By this my colleague mentioned the purpose of the custom Error message on the

    Edit Field > Settings > Require

    This message will show if the visitor does not write anything in the particular field and tries to submit the form.

    You can see this by trying to submitting the form leaving this required field empty. https://forminator.amartest.site/test-required/

    The Error Message in Require is not related to the Limit settings (validation). The error message related to the Limit settings will only appear when the visitor enters a value in the field and the value does not passes the limit settings.

    For example in this case when the Minimum is set to 1 and Maximum is set to 150 like

    if a visitor fills this field with a value less than 1 and higher than 150 then the validation error message will show according to the limit.

    You can test it by adding any value to this field less than 1 or higher than 150.

    Hope this clarifies.

    Please feel free to contact us if you need any more help.

    Regards,

    Sohag

  • Panos
    • SLS

    Hi F404 !
    Until the redirect to same tab issue is fixed on next release, you can try out adding he following snippet in a mu-plugin:

    add_action( 'wp_ajax_forminator_save_builder', function(){
    
    $form_id = 303;
    
    if ( ! current_user_can( 'manage_options' ) || ! isset( $_POST['data'] ) || ! isset( $_POST['form_id'] ) || $form_id != $_POST['form_id'] ) {
    return;
    }
    
    forminator_validate_ajax( "forminator_save_builder_fields" );
    
    $form_data = json_decode( stripslashes_deep( $_POST['data'] ), true );
    $form_data['settings']['newtab'] = 'sametab';
    
    $_POST['data'] = wp_slash( json_encode( $form_data ) );
    
    }, 9 );

    Make sure you replace your actual form id in this line:
    $form_id = 303;
    If you are not familiar with mu-plugins, you can read about them here :
    https://premium.wpmudev.org/manuals/wpmu-manual-2/using-mu-plugins/
    You can also add it in the child theme’s functions.php but make sure yo uare using a child theme so the file doesn’t get re-written on theme update.
    After adding the above snippet, go to your form in the admin and re-save it. Let us know if after that your form still redirects to new tab.
    Kind regards!

  • Adam Czajczyk
    • Support Gorilla

    Hello F404

    when will be next release (fix redirect to same tab issue)?

    I’m afraid I don’t have any ETA and we usually don’t settle “fix dates” as there’s a lot of things to be carefully tested before releasing each update. However, Forminator updates are quite frequent and it should be released quite soon, I believe.

    Kind regards,

    Adam

    • Adam Czajczyk
      • Support Gorilla

      Hello F404

      Thank you for your feedback, I’ll surely pass it on to my superiors.

      Please note though: we’ve provided you with a patch for the issue that’s fixing it until the properly fixed plugin is released. As my colleague stated it’s going to be the nearest release. The only thing I don’t know is the specific date but I’m sure it’s going to be published pretty soon. It’s very important to run entire release through tests to make sure that the patch doesn’t break/affect anything else and is not/will not interfere with any new/upcoming features. I understand and fully agree that such bug shouldn’t ever see the light of the day in the first place but, unfortunately, bugs do happen – not only in our plugins. We do our best to avoid them and to improve all the QA testing process.

      That being said, let me apologize for any trouble that this might cause to your and assure you that we’re doing what’s humanly possible to get better and better and to improve testing procedures. I have also passed on your feedback to our managers.

      Thank you for helping us improve!

      Best regards,

      Adam

  • Panos
    • SLS

    Hey F404 ,
    Apologies for missing this! Till the release with the fix is out, you can either add multiple form ids in the following modified snippet:

    add_action( 'wp_ajax_forminator_save_builder', function(){
    
    $form_ids = array( 7, 32, 184, 303 );
    
    if ( ! current_user_can( 'manage_options' ) || ! isset( $_POST['data'] ) || ! isset( $_POST['form_id'] ) || ! in_array( $_POST['form_id'], $form_ids ) ) {<br />
    return;
    }
    
    forminator_validate_ajax( "forminator_save_builder_fields" );
    
    $form_data = json_decode( stripslashes_deep( $_POST['data'] ), true );
    $form_data['settings']['newtab'] = 'sametab';
    
    $_POST['data'] = wp_slash( json_encode( $form_data ) );
    
    }, 9 );

    in which you need to replace the form ids in the line:
    $form_ids = array( 7, 32, 184, 303 );
    or you can apply that for all forms without checking form ids at all:

    add_action( 'wp_ajax_forminator_save_builder', function(){
    
    if ( ! current_user_can( 'manage_options' ) || ! isset( $_POST['data'] )  ) {
    return;
    }
    
    forminator_validate_ajax( "forminator_save_builder_fields" );
    
    $form_data = json_decode( stripslashes_deep( $_POST['data'] ), true );
    $form_data['settings']['newtab'] = 'sametab';
    
    $_POST['data'] = wp_slash( json_encode( $form_data ) );
    
    }, 9 );

    Just keep in mind that the last one will force to redirect on same tab for all forms.
    Kind regards!

  • Panos
    • SLS

    Hi F404 !

    Sorry to hear you have issues with that. I tested all snippets shared above several times also asked from a colleague to confirm. Could you share admin and ftp access to your site so I could have a closer look?

    You can send that privately through our contact form: https://premium.wpmudev.org/contact/#i-have-a-different-question

    Send in:Subject: “Attn: Panos Lyrakis”

    – Admin login:

    Admin username

    Admin password

    Login url

    – FTP credentials

    host

    username

    password

    (and port if required)

    – link back to this thread for reference

    Kind regards!

  • F404
    • Flash Drive

    Hello

    Please test in your dev site. I test it several times and snippet have bug. (Use snippet which apply for all forms wl)

    I lost entry of form and i think it is not possible to restore.

    I send screenshot how it look if i want export and how look submissions.

  • Panos
    • SLS

    Tested again and works fine on my sites. For more technical information that snippet doesn’t affect anything else than the option about the new tab. So it shouldn’t be affecting entries. Not sure if form Field types or other settings would affect, it is even possible that the snipped hasn’t been added correctly in a mu-plugin. That’s why I have asked for access above. I would suggest to use a staging site and send information about that site, it would make things quicker as I don’t have any other suggestion on how else we could help out here.

    Kind regards!

  • F404
    • Flash Drive

    I make fresh install and it have same problem, use this steps:

    You must have some forms

    1. put this code

    2. Edit some form you have and refresher page or try open again same form with edit – form and it entry is destroyed

    3. also you can not create new forms

    P.S.

    In this ticket i get answers from support

    “Until the redirect to same tab issue is fixed on next release”

    From that time when i inform about this bug there was 4 updates but no fix!!!!

  • Panos
    • SLS

    Thanks for sharing this info F404 !
    It was very helpful!

    There is a bug in the above ones, will edit replies there to avoid confusion. The snippets should be:

    1. For specific form(s):

    
    add_action( 'wp_ajax_forminator_save_builder', function(){
    
    	$form_ids = array( 7, 32, 184, 303, 4406 );
    
    	if ( ! current_user_can( 'manage_options' ) || ! isset( $_POST['data'] ) || ! isset( $_POST['form_id'] ) || ! in_array( $_POST['form_id'], $form_ids ) ) {
    	return;
    	}
    
    	forminator_validate_ajax( "forminator_save_builder_fields" );
    
    	$form_data = json_decode( stripslashes_deep( $_POST['data'] ), true );
    	$form_data['settings']['newtab'] = 'sametab';
    
    	$_POST['data'] = wp_slash( json_encode( $form_data ) );
    
    }, 9 );
    

    And 2. for all forms:

    
    add_action( 'wp_ajax_forminator_save_builder', function(){
    
    	if ( ! current_user_can( 'manage_options' ) || ! isset( $_POST['data'] )  ) {
    		return;
    	}
    
    	forminator_validate_ajax( "forminator_save_builder_fields" );
    
    	$form_data = json_decode( stripslashes_deep( $_POST['data'] ), true );	
    	$form_data['settings']['newtab'] = 'sametab';
    
    	$_POST['data'] = wp_slash( json_encode( $form_data ) );
    
    }, 9 );
    

    Please test this first in a staging site before moving in a production site.

    Let us know if you still have this issue.

    Kind regards!

  • Panos
    • SLS

    Yes I saw the video and I could replicate!

    This is the line that is now changed:
    $_POST['data'] = wp_slash( json_encode( $form_data ) );

    In the original code those should be there other way around, concluding in a different json string.

    Have you tested it and still doesn’t work?

  • Panos
    • SLS

    Hi again F404 !

    Was talking with Patrick Freitas who noticed that you might actually not need the snippet. You can try the following instead:

    1. Go to the Behaviour tab
    2. Check the “Redirect on new tab and hide…” but do not save changes
    3. Then check the “Redirect on same tab” option.

    This is not how it is supposed to work, so it will be fixed, but his is another workaround I wasn’t aware of that seems to be saving it properly. Worked on Patrick’s and my site too, so it sounds worth trying that out too :slight_smile:

    Kind regards!

    • F404
      • Flash Drive

      Hi
      what you mean:
      1. Go to the Behaviour tab
      2. Check the “Redirect on new tab and hide…” but do not save changes
      3. Then check the “Redirect on same tab” option.

      Now I have Behaviour tab “Redirect on same tab” .
      What i must do, Check the “Redirect on new tab and hide…” but do not save changes, then check “Redirect on same tab” option and save ?

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.