Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

Post Timeline

Source Link
Alan H.
  • 16.7k
  • 17
  • 85
  • 116

Use Rails’ form_for but set custom classes, attributes on <form> element?

form_for seems to ignore any 'extra' attributes like a data-foo attribute or class passed as options in its second argument.

= form_for @user, {:url => 'foo', :class => 'x', 'data-bar' => 'baz' } do |f|
 # ...

The output is a <form> tag with no x class or data-bar attribute.

What’s the fix?

Or, how can I grab a FormBuilder instance without using form_for?

lang-rb

AltStyle によって変換されたページ (->オリジナル) /