Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a class to f.submit but keep default functionality?

Very simple question, I have:

<%= f.submit %>

I want to apply class='btn' to it. I know that I can easily do this:

<%= f.submit 'Button Name', :class => 'btw' %>

But...how do I achieve the same thing, i.e. apply a class without specifying a static name for the button?

In other words, given that I am doing this in my form partial, I want the name of the button to change according to the action being called (i.e. new, create, update, etc.). So how do I get the best of both worlds?

like image 291
marcamillion Avatar asked Jan 10 '12 22:01

marcamillion


1 Answers

<%= f.submit nil, :class => 'btw' %>

or even

<%= f.submit :class => 'btw' %>
like image 53
Damien Avatar answered Oct 20 '22 22:10

Damien