Copied to clipboard

Flag this post as spam?

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


  • Max 80 posts 437 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 6132 posts 23951 karma points MVP 7x 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 80 posts 437 karma points
    Aug 31, 2018 @ 15:30
    Max
    0

    That will prevent the post back as well, correct?

    Thanks, Max

  • Namrata 8 posts 78 karma points
    28 days ago
    Namrata
    0

    Hello Max,

    I am trying to achieve a similar behaviour to inject some logic before the actual on-submit kicks in and then continue the rest of the workflow as it is. If you were able to achieve this or any custom solution you made to make it possible can you please share it ?

    Thanks, Namrata

  • Max 80 posts 437 karma points
    28 days ago
    Max
    0

    Namrata,

    This issue was quite a long time ago, I'm not actually sure what the resolution was.

    I can definitely say, I probably did not try that solution - it was not part of the Umbraco backend.

    Max

Please Sign in or register to post replies

Write your reply to:

Draft