Add a CSS class to <%= f.submit %>

sscirrus picture sscirrus · Mar 15, 2011 · Viewed 132.3k times · Source

My question is easy:

<%= f.submit %>

Where does the class declaration go? I'm getting errors on multiple attempts.

Answer

Srdjan Pejic picture Srdjan Pejic · Mar 15, 2011
<%= f.submit 'name of button here', :class => 'submit_class_name_here' %>

This should do. If you're getting an error, chances are that you're not supplying the name.

Alternatively, you can style the button without a class:

form#form_id_here input[type=submit]

Try that, as well.