Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you override the class name in the form_for helper?

I need to add some class names to my form. I'm using Rails' form_for helper to do this. I've tried adding { :class => 'classname' } to no avail.

How can I add classes to this Rails helper output?

like image 740
James Avatar asked Jul 30 '11 06:07

James


2 Answers

Try this:

form_for @order, :html => {:class => "foo"} 
like image 106
Harish Shetty Avatar answered Sep 28 '22 03:09

Harish Shetty


For Rails 4.0 here is the example from the guides:

http://guides.rubyonrails.org/form_helpers.html

1.2 Multiple Hashes in Form Helper Calls

form_tag(controller: "people", action: "search", method: "get", class: "nifty_form") # => '<form accept-charset="UTF-8" action="/people/search?method=get&class=nifty_form" method="post">' 
like image 28
Daniel Avatar answered Sep 28 '22 01:09

Daniel