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?
Try this:
form_for @order, :html => {:class => "foo"}
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">'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With