tyxla / Gravity-Forms-Multiple-Form-Instances

Allows multiple instances of the same form to be run on a single page when using AJAX.
GNU General Public License v2.0
38 stars 22 forks source link

Forms with conditional logic broken since GF 2.5.3 (fix included) #42

Open elliott-w opened 3 years ago

elliott-w commented 3 years ago

Since Gravity Forms 2.5.3, they made it so that form scripts are printed in the footer rather than in the form itself. This made it so that this plugin couldn't modify the form ids in the $form_string and thus broke the plugin. The fix is to make sure scripts always get printed inside the form itself:

add_filter('gform_init_scripts_footer', 'print_scripts_in_form');
function print_scripts_in_form($bool) {
  return false;
}

You can add that code snippet inside the __construct() function of the gf-multiple-form-instances.php file or inside your theme's functions.php file.

Also I'm not sure when the quotes were changed, but you should also change the line: "id='field_" . $form['id'] . '_' => "id='field_" . $random_id . '_', with: 'id="field_' . $form["id"] . "_" => 'id="field_' . $random_id . "_",

Also it seems the Google Recaptcha v3 add-on doesn't work for multiple instances of the same form on a single page. I would recommend disabling recaptcha specifically for those forms.

TehKonnos commented 2 years ago

Thank you very much! Indeed it works very good with conditional logic!