ideas
ideas copied to clipboard
A way to override form submission email sending
It would be nice if there was a way developers could override the saving of form submissions. Similar how they could in v2 with the Form.submission.creating event.
Use Case
I'm porting over a site from v2 to v3 which has quite a bit of custom logic around forms.
One of those bits of logic is where we change the email form submissions get sent to. We have a form where the user selects a 'Branch'. Then in our v2 listener, we get the entry for that branch, grab it's email field and we replace {{ branch_email }} with the branch's email address (if the branch is one of the configured email addresses).
I had a look but there's currently only a single event for submissions: SubmissionCreated which isn't very helpful (I'm happy to include support for Submissions in statamic/cms#3379 btw if you think that would work)
Workaround
Right now, I've done a bit of a hacky workaround. Extended the form tag to use a custom controller which extends Statamic's FormController that then dispatches a custom version of the SendEmails job which I then have a three line check in to replace {{ branch_email }} with what it should be. đŸ˜…