zulhfreelancer
12/9/2015 - 7:57 AM

How to add class to Rails form helper submit button?

How to add class to Rails form helper submit button?

First option:

<%= f.submit 'name of button here', :class => 'submit_class_name_here' %>

Second option:

<%= f.submit class: 'submit_class_name_here' %>


Usage situation

Use first option if you want to specify static button text.

Use second option if you want to make the button text dynamic based on the Rails method name like create will become Create User and update will become Update User.