'Popup shown less than' rule breaks Gravity Form ajax submission

With the rule 'Popup shown less than n times' enabled, and the value set to 1 (ie show the popup once only), the submission of an AJAX Gravity Form embedded in the popup is broken.

Gravity Forms correctly handles the request (ie notifications emails are sent etc) but instead of the form refreshing with the AJAX response, (ie the GF confirmation) the form closes. It does this, because the AJAX response is empty.

Examining the ajax request, i see that the submission to the form handler from within the popup gets the _po_method_=raw value appended to it, the class-popover.public.php then sees this value, observes that the form has already been shown once (the limit) and decides to die(), returning an empty response, stripping the confirmation.

Changing the value of the 'Popup shown less than' value to 2, instead of 1, fixes the issue.

The setting for form behaviour is correct for an ajax response (ie Refresh popup or do nothing).

To reproduce the issue, adjust the form settings for "Popup shown less than" to 1, flush cookies, and try a submission - the dialog will close when the response is received. Repeat with "Popup shown less than" set to 2, flush cookies, and submit - the confirmation will be seen.

Support access has been granted.

  • Ash
    • WordPress Hacker

    Hello @Hugh

    Welcome to WPMU community!

    I hope you are doing good and thanks for asking the question :slight_smile:

    Please note that, if you use "Popup shown less than n times" then the popup will show ( n-1 ) times. So, to perform popup only once, you have to use 2 in that field.

    To be honest, I am sorry that I am not 100% clear about your issue. Would you please briefly explain again? Maybe rephrase?

    Have an awesome day!

    Cheers
    Ash

  • Hugh
    • WPMU DEV Initiate

    Thanks for the reply.

    First off, I don't see the (n-1) behaviour that you claim. As the attached cap states, the label on the field is clearly "Show Popup this often" and with a 1 in the box, and no cookies set, I see the popup, as expected, once.

    But, with this value set to 1, I can see that although the popup is seen, the form submission within it is broken - I observe an empty response from the AJAX request, when I should see Gravity Form's AJAX confirmation. The result of this is, the popup closes when the ajax submission completes.

    Set the value to 2, and the popup is seen, and the form submission works correctly - the page returns the correct Gravity Form's AJAX confirmation, and the popup redraws to show this.

    Looking at the source code of class-popover.public.php and how this 'raw' tagged AJAX request is handled, and I can only assume that the AJAX form submission is being counted as an attempted second viewing of the dialog, resulting in the empty response.

    To summarise: If disable the condition, or set the value to 2, and form submission works. I set the value to 1, and the popup is shown, but the form is broken. It looks like a bug to me.

  • Ash
    • WordPress Hacker

    Hello @Hugh

    You are absolutely right!

    I can confirm the issue in my test site. So, I am marking this as a bug and reporting to the developer.

    Thanks for reporting this, sending some points in your way :slight_smile:

    Have an awesome day!

    Cheers
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.