Reputation: 314
I was looking through this response to having different paths to a second submit button How do I create multiple submit buttons for the same form in Rails?, and ended up using formaction: my_path
to specify the new path.
This works nicely if the form has the same method i.e. POST, but doesn't seem to work if the form requires a different method.
I was wondering whether anyone knew a neat solution like the formaction: my_path
solution or a rails helper or if in fact the best way forward is to reset the method via JS.
Upvotes: 1
Views: 1217
Reputation: 314
Managed to find out what it was for those who are interested, there is an html element 'formmethod' that you can set to give the request a different method.
Here's a non-rails example from W3 schools - https://www.w3schools.com/html/html_form_attributes.asp
<form action="/action_page.php" method="get">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="Submit">
<input type="submit" formmethod="post" value="Submit using POST">
</form>
Upvotes: 1