Copied to clipboard

Flag this post as spam?

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


  • Angelo 111 posts 260 karma points
    Oct 01, 2018 @ 13:30
    Angelo
    0

    Form name and data after submit

    Hello Nicholas is there a way to know witch form (and data) was submited here ...

    $scope.$on("Formulate.formSubmit.OK", function () {
    
    });
    

    thank you

    Angelo

  • Nicholas Westby 2054 posts 7104 karma points c-trib
    Oct 01, 2018 @ 16:17
    Nicholas Westby
    0

    Here's where that form data is emitted from: https://github.com/rhythmagency/formulate/blob/2300607bae189811aff4533208aef1218611fbec/src/formulate.frontend/responsive.bootstrap.angular/directives/form/responsiveForm.js#L59

    Looks like it includes the form name:

    this.post = function (data, $scope) {
        function postSuccess(response) {
            $scope.$emit('Formulate.formSubmit.OK', {
                fields: data.postData,
                name: data.name,
                response: response.data
            });
        }
    

    You can get access to the data by using a parameter in your event handler function:

    $scope.$on("Formulate.formSubmit.OK", function (data) {
        // Do something with data.
    });
    

    Use your debugger or console.log to inspect the properties on data.

  • Angelo 111 posts 260 karma points
    Oct 01, 2018 @ 18:58
    Angelo
    0

    Hello Nicholas

    $scope.$on("Formulate.formSubmit.OK", function (data) {
     alert(data.name);
    });
    

    if i do like this i receive "Formulate.formSubmit.OK" on the data.name parameter ... am i doing something wrong or miss something ? and i did the inpsect and i cannot see nothing with the name and data from the form

    thank you

    Angelo

  • Nicholas Westby 2054 posts 7104 karma points c-trib
    Oct 01, 2018 @ 21:22
    Nicholas Westby
    1

    Looks like the first parameter is the event, and the second parameter is the data. So you'd do:

    $scope.$on("Formulate.formSubmit.OK", function (event, data) {
     alert(data.name);
    });
    
  • Nandoh 32 posts 104 karma points
    Oct 09, 2018 @ 11:00
    Nandoh
    0

    Hi Nicholas,

    that 'data' in the formSubmit.OK has an inner property called 'fields' with all the fields sent in the request. However it's constructed as a fieldMap with the fields' Ids - and not the fields' alias.

    Is there any way to use the "alias" to get a specific field? (I would like to present a message like this after the user submits the form => "A copy of your request has been sent to your email address '[EMAIL]'" )

    Thank you. Regards

  • Nicholas Westby 2054 posts 7104 karma points c-trib
    Oct 09, 2018 @ 17:30
    Nicholas Westby
    0

    Busy week, so I'll have to keep my response brief. Some ideas:

    • Submit a pull request to add this (it already exists as part of the new plain JavaScript template).
    • Create a secondary map of GUID field ID to field alias and look it up with some of your code.
    • Figure out the GUID field ID for the email field and use that rather than the field alias.
  • Angelo 111 posts 260 karma points
    Oct 02, 2018 @ 10:16
    Angelo
    0

    thats it :D

    thank you

    Angelo

  • 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