• Resolved chladog

    (@chladog)


    Hello,

    Everything is working good. But after form is submited on frontend and success message appeared* then when you refresh the page (F5) form resubmits again and get to the Entries and another set of emails get sent again. Normal behavior would be to show new blank form, or at least success message but without resubmitting the data.

    *Also it would be great to have hook for success message so we could set default message in PHP when is not set in the backend.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author fabianlindfors

    (@fabianlindfors)

    Hi! I’m glad AF is working out for you.

    The form resubmission is intended behavior and it’s because the form performs a POST request and then doesn’t redirect afterwards. Most browsers (think I’ve tested Chrome, Safari, and Firefox) should warn you that the form will be resubmitted, doesn’t yours?

    I have thought about changing as I’ve been a bit worried that double submissions could occur, a worry you have now confirmed. I’ll have to think it through!

    Regarding the success message hook that’s a very good idea, I’ll probably add it for an upcoming version. If you want to achieve something similar right now you can hook into the af/form/before_render (documentation) to change the success message. Here’s a (non-tested) example:

    `
    function change_success_message( $form, $args ) {
    $form[‘display’][‘success_message’] = ‘New success message’;
    return $form;
    }
    add_filter( ‘af/form/before_render’, ‘change_success_message’, 10, 2 );
    `

    Hope it works!

    Thread Starter chladog

    (@chladog)

    Thank you!

    FYI my browser Chrome 61.0.3163.100 (default settings) doesn’t ask about resubmitting.

    • This reply was modified 7 years, 4 months ago by chladog.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Form resubmits on refresh’ is closed to new replies.