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?
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 it possible to handle more than one submit button?
Hi All
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.
https://our.umbraco.com/forum/templates-partial-views-and-macros/90611-how-to-i-implement-two-submit-buttons-in-the-same-partial-view-hitting-the-same-surface-controller
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:
You can read more about it here: w3schools link
Hi Emiel
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.
Appreciate for your help.
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?
Hi Emiel
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.
Hi javafun,
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.
Thanks
Craig
is working on a reply...