Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Max 76 posts 432 karma points
    Aug 21, 2018 @ 18:23
    Max
    0

    Umbraco forms - on submit

    I want to hijack the "on-submit" event. I have a database table that I want to save the form data to but i have specific pre-insert logic I need to perform. I created the form from my datasource, my workflow doesn't trigger until it's too late. Umbraco Forms tries to save the record before I can inject the necessary values for my database constraints (not part of the form data.)

    My assumption is that I need to get to the on-submit event before the postback occurs?

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Aug 31, 2018 @ 14:49
    Alex Skrypnyk
    0

    Hi Max

    You can try to use javascript to hijack the "on-submit" event. Like that:

        $('#umbraco_form_' + formId + ' form').on('submit',
            function (e) {
                e.preventDefault();
    
                var $form = $(this);
    
                if ($form.data('submitted') === true) {
                    // Previously submitted - don't submit again
                } else {}
       })
    

    Thanks,

    Alex

  • Max 76 posts 432 karma points
    Aug 31, 2018 @ 15:30
    Max
    0

    That will prevent the post back as well, correct?

    Thanks, Max

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies