Skip to content

Support the SubmissionFinalizing event in automagic forms - #37

Draft
duncanmcclean wants to merge 1 commit into
1.xfrom
submission-finalizing
Draft

duncanmcclean wants to merge 1 commit into
1.xfrom
submission-finalizing

Conversation

@duncanmcclean

Copy link
Copy Markdown
Member

This pull request adds support for core's new SubmissionFinalizing event to automagic forms.

When a SubmissionFinalizing listener holds a submission, it's kept as a partial rather than being finalized. However, automagic forms stored the held submission in the session as the resumable partial and sent the user back to the first page, so they never reached the checkout (or the success page) and could submit again.

This PR fixes it by:

  • Only storing the partial submission in the session when there's a next page, matching core's FormController.
  • Returning the listener's redirect URL when it returns a RedirectResponse (eg. to a payment checkout).
  • Showing the success page when there's no next page, whether the submission was finalized or held by a listener returning false.
  • Doing a full page navigation for redirects to other origins, since Inertia's router.visit() makes an XHR request, which fails for external URLs.

This PR depends on the core PR. The statamic/cms constraint will need bumping once it's merged and tagged, so CI will fail until then.

Related: statamic/cms#16069

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant