I have a Sitecore 8.1 WFFM
form in an MVC form rendering, with a save action that takes a few seconds to complete. After submitting the form, the user just sees the form page they submitted with no message to show that it is processing, until the server finishes the save actions and redirects to the success page or shows the success message. This seems to be the same regardless of whether the Is Ajax Mvc Form
checkbox is selected or not for the WFFM form.
During this wait the user might try resubmitting the form again, which I need to prevent.
Example code for a slow save action is:
using System;
using System.Configuration;
using Sitecore.Data;
using Sitecore.WFFM.Abstractions.Actions;
using Sitecore.WFFM.Actions.Base;
namespace Sitecore.Custom.Forms.SaveActions
{
public class SlowSaveAction : WffmSaveAction
{
public override void Execute(ID formId, AdaptedResultList adaptedFields, ActionCallContext actionCallContext = null, params object[] data)
{
System.Threading.Thread.Sleep(8000);
}
}
}
I have tried editing the default FormViewModel.cshtml
with javascript to disable the submit button after the form is submitted (which works in pre-mvc versions of WFFM), but because the mvc form is dynamically reloaded after clicking submit, the button is immediately reset to enabled.
I have also looked in the Sitecore.Forms.Mvc.ViewModels.FormViewModel
model for any value that might identify that the form is submitted and validation passed, but couldn't find anything.
Is there some way to disable the submit button whilst the form is processing? Or perhaps as an alternative, hide the button and show a 'processing' message?