Ad

Is Possible To Have Multiple Data Requests In Octobercms Form?

I have this data-request from Mailchimp plugin where I send form data to Mailchimp API.

 <form data-request="{{ mailSignup }}::onSignup"
       data-request-update="'{{ mailSignup }}::result': '#{{ mailSignup.id }}container'" class="book" id="bookit">

Is there a way to join another data-request from Mail plugin (genericFrom)?

This data-request send's e-mail on form submit. Goal is to have two data-requests in the same form.

First request have to send form data to Mailchimp API and second request should send E-mail.

<form data-request="{{ genericForm }}::onFormSubmit">

I'm trying to achieve something like this:

<form data-request="{{ mailSignup }}::onSignup, {{ genericForm }}::onFormSubmit"
       data-request-update="'{{ mailSignup }}::result': '#{{ mailSignup.id }}container'" class="book" id="bookit">
Ad

Answer

Yes with the javascript api instead of using the data-request attributes.

[Check here for documents][1] [1]: https://octobercms.com/docs/ajax/javascript-api

$("form").submit(function(){
    $(this).request('{{ mailSignup }}::onSignup', {
       /* Update or send data */
    })
    $(this).request('{{ genericForm }}::onFormSubmit', {
       /* Update or send data */
    })
});
Ad
source: stackoverflow.com
Ad