Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am running into this issue recently. The current form has one submit button does post to the surface controller to persist the form data.
My client has a new requirement and would like to add another button on the same form to allow their users to save the data as draft.
I went through the forum and google, found the following similar question, unfortunately, there wasn't clear solution to fix this issue.
Can someone point me a direction how to handle multiple submit buttons with Umbraco surface controller?
Appreciate for your help.
What I've used is the "formaction" attribute. Example:
<form class="form" action="/url" method="get">
<input class="input" placeholder="Name">
<input class="submitbutton" type="submit" value="Submit form">
<input class="link" formaction="/different-action" value="Submit to different action" type="submit">
You can read more about it here: w3schools link
Thanks for your quick response.
In your code snippet, you specify method="get" in the form tag, is this the trick to handle multiple form post?
My form used formaction and generate via @Url.SurfaceAction, however the only difference to your example is the form method, it turns out no matter which button I clicked, it always post to the form's action, not the formaction I specified in the button.
Whether it is "POST" or "GET" shouldn't be the issue, the page it was submitting to was a Vue app which had additional parameters needed, hence the usage of "GET".
Honestly, I'm not really a big fan of using either @Url.SurfaceAction or @Html.BeginUmbracoForm, could you try to make the form in html, and then try to add the route you're trying to hit to those buttons?
Again, thanks for your response.
However, I think you suggested approach only works if I register MVC standard route, meanwhile I lose all Umbraco context e.g. I'm no longer able to use return CurrentUmbracoPage if validation failed. I have to complete change the way how I handle the entire form which is not very ideal for my current situation.
If you can't get it working using the suggestions Marc posted on the the previous post you mentioned...
Then I would say the easiest solution for this would just to create a second partial view which POST's directly to your new Action method on your current SurfaceController.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted