data['extra_imgcorp'] == '1') ){ $form->actions_config[6]["enabled"] = 1; }else { $form->actions_config[6]["enabled"] = 0; }?>Example: If I put "send email" action after "File Download" action it doesn't work. But If I move "Send Email" before "File Download", it works.In any case, the submit actions didnt finish, because once the file has downloaded, the form stops (didnt go to a new page (confirm) or similar.>> Could you help me, please?(I cannot attach image to the post, sorry)"> Failure on submit actions before file download - Forums

Forums

Failure on submit actions before file download

Kronosites 11 Feb, 2017
Hello!

I'm doing a form that downloads a file to the user depending of checked or unchecked variables.
All is working fine excepts that all the actions that I put after the "file download" action on submit event.

Here the code that I use to enable or disable the file download action:
<?php
if ( !empty($form->data['extra_imgcorp']) && ($form->data['extra_imgcorp'] == '1') )
{ $form->actions_config[6]["enabled"] = 1; }
else { $form->actions_config[6]["enabled"] = 0; }
?>


Example: If I put "send email" action after "File Download" action it doesn't work. But If I move "Send Email" before "File Download", it works.

In any case, the submit actions didnt finish, because once the file has downloaded, the form stops (didnt go to a new page (confirm) or similar.

>> Could you help me, please?
(I cannot attach image to the post, sorry)
GreyHead 11 Feb, 2017
Hi Kronosites,

You could use an Event Switcher for this rather than over-riding the configuration.

The File Download action needs to be the last action as it takes over control from ChronoForms.

An alternative way to handle this is to add a download link to the Thank You message (and/or in an email). You can then include/exclude the link using a Custom Code action to build the HTML.

Bob
Kronosites 11 Feb, 2017
Ok, thanks Grey.

Then I found a possible solution (bad solution, but for me is enough)
I'll explain for all the users and, of course, up to you to improve it😉

The objetive is to show something different to users when on-click submit button, just to let them know "all has work OK, thanks". I use jQuery code to show/hide 2 different buttons (buttons, divs, etc) to change the message to users and execute submit event.

The only problem is that only works if there's no error on the fields of the forms. At the time that the form validation encounters an error, the form will not be sent and, hiding the submit button, will not be able to execute either.

That is, all fields should be unvalidated so that the form is sent regardless of the type of information added, the first time the submit button is clicked.

This is what I put on my form:

- On setup tab (before HTML load action)
jQuery that hides submit button and shows another button (disabled) saying "thanks guy!":
jQuery(document).ready(function(){
    jQuery('#hideshow').live('click', function(event) {        
         jQuery('#finalcontainer').toggle('show');
    });
    jQuery('#hideshow').live('click', function(event) {        
         jQuery('#finish').toggle('show');
    });
});


- On design tab:
Here the submit button (custom code):
<div id='finalcontainer' style="width:100%"><center><button id='hideshow' style="max-width:100%" type="submit" class="button button-block"><h2>¡TEXT!</h2></button></center></div>


- On design tab:
Here the second button (disabled) just to say "thanks" to users:
<div id='finish' style="width:100%;display:none"><center><button style="max-width:100%" class="button button-block" disabled><h2>¡THANKS TEXT!</h2></button></center></div>
GreyHead 12 Feb, 2017
Hi Kronosites,

I suspect that you posted this in the wrong thread - it doesn't seem to have anything to do with file uploads?

Bob
Kronosites 12 Feb, 2017
Hello Grey!

Sorry, I did not express myself correctly.

Since we cannot add more actions after file download action on submit event and, usually we need to give to our users some visual step when click on submit button (because the file download could fail, f.e.), my "solution" to give this, a "visual end" of the form to the user is use jQuery to hide/show different sections of the form (in the example, hidding submit button and showing thanks button).

It's a pity that File Download takes over control from ChronoForms, but i'm loving the versatility of CF😉
GreyHead 13 Feb, 2017
Hi kronosites,

I think we have some confusion here. A** File Download** action is used in the form On Submit event to deliver a file to the user. I think that you are talking about a **Files Field** + **Files Upload** action which is used to allow the user to upload a file to the server.

Is that correct?

Bob
Kronosites 14 Feb, 2017
Hi again GreyHead,

No, no, I'm speaking always about "File Download" action on submit event.

In summary, if we create a complex form with lot of actions in submit event, it's always necessary, as you said before, to add all the actions before the File Download action.

And thats really a problem because when the users click on "submit" button, nothing happens except the file download. I mean, the form doesn't change, it doesn't show a thanks message, or something like that. Ok, the file downloads, but if your form is used also to get data, the user doesn't really know if the information have been sent or not.

So, the only solution to show something to the user saying "ok, your information have been sent correctly" is use jQuery to hide part of the form and show another part, which loads hidden and only appears when the user clicks on submit button (we can use HTML5 or javascript also).

I would love to add images to the forum, but the "attachments" screen doesn't works, I don't know why!
GreyHead 15 Feb, 2017
HI chronosites.

As I said before "An alternative way to handle this is to add a download link to the Thank You message (and/or in an email). You can then include/exclude the link using a Custom Code action to build the HTML."

Or you can show a thank you page with a 'download file' button that loads another form event with just the download action.

Bob
This topic is locked and no more replies can be posted.