I notice that every time a Rails form is sent to the server, the name of the submit button (usually the string that is displayed on the button) is included in the params
hash as "commit".
For example (last entry)
{"utf8"=>"✓",
"authenticity_token"=>"eZABpBuW7afziDMUJtc1BNEKvGyI7NlTd9+NOYqnMxs=",
"order"=>{"name"=>"marco",
"email"=>"[email protected]",
"phone"=>"0839457382",
"collection"=>"0",
"address"=>"18 main street, paarl",
"city"=>"paarl",
"country"=>"South Africa",
"zip"=>"7646",
"instructions"=>""},
"terms"=>"on",
"commit"=>"Next: 3. Payment"}
What is the purpose of this?
Is it a result of me formatting my forms incorrectly?
Here is my submit button for this specific example, taken from my form_for
block
<%= f.submit 'Next: 3. Payment', :class => 'right button' %>
(The classes right button
are from foundation forms.
Its a way to discriminate which submit button was pushed. Could be useful if you have very different actions like:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With