Can I run a flow on submit and then POST(needs to be a POST) the request to SC from the same flow?
It’s driving me crazy and I see this use case as a pretty basic one for flows and forms
I’ve tried several combinations and haven’t managed to do it.
I want to achieve this.
$('#myform').submit(function() {
return myflow.run()
});
...
//flow run function
function run() {
if (condition)
return true //submit form
else
return false //cancel submit
}
That won’t work that way, flows are async and uses promises. To use a flow in a form submit you should prevent the submit event and then at the end of the flow you call the submit method of the form (this should not trigger the submit event again).
$('#myform').on('submit', function (e) {
e.preventDefault();
myflow.run()
});
//flow run function
function run() {
if (condition)
$('#myform').submit()
else
return false
}
And if so is using dmx-on:submit.prevent the right approach?