Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does submit_tag generate HTML with the name="commit" property?

As per the rails docs, using the submit_tag helper will generate something like

submit_tag
# => <input name="commit" type="submit" value="Save changes" />

It includes the property name="commit"

  • Why does this get included? Is it some sort of standard? Trying to understand what "commit" means in this context

  • I noticed it gets included in the params inside the controller after hitting submit. Was this changed recently? I thought only url params and POST/PUT data get included?

    @params

    => {"utf8"=>"✓", "authenticity_token"=>"4q3u+mfMi57YbchTAzaCI7WHmzfZJrLbTZ17aVwfq9uw8aMU1B3PBR13qfipgN6lbRoi0dywFU9i1AbJ0GP7UA==", "email"=>"[email protected]", "password"=>"(REDACTED)", "dest"=>"", "commit"=>"Log in", "controller"=>"sessions", "action"=>"log_in"}

Thanks!

like image 847
user2490003 Avatar asked Oct 17 '22 12:10

user2490003


1 Answers

I believe this is just a rails thing. HTML5 standards allow you to provide a name=xxxx on your own, which you can also do with rails. In short, name="commit" helps in case you need to do something like this guy and makes sure something is passed in the parameters.

like image 113
Godzilla74 Avatar answered Nov 15 '22 04:11

Godzilla74