Search code examples
ruby-on-railsformtastic

ruby on rails - formtastic - form class


I have a form built with formtastic, the code is

<%= semantic_form_for @plan, :html => { :class => "form-horizontal" } do |form|%>
    <%= form.input :name %>
    [..some inputs here...]
    <%= form.buttons%>
<%end%>

but the form isn't getting the class "form-horizontal", the generated code is

<form id="new_plan" class="formtastic plan" novalidate="novalidate" method="post" action="/plans" accept-charset="UTF-8">
    [...inputs/actions...]
</form>

Why?

I'm using formtastic 2.1, gemfile:

gem 'formtastic', :git => 'https://github.com/justinfrench/formtastic.git', :branch => "2.1-stable"

Thanks in advance


Solution

  • You need to wrap your html options in another hash

    <%= semantic_form_for @plan, {:html => { :class => "form-horizontal" }} do |form|%>
    

    It dose seem weird but I had that problem before, and the above solved it.

    Hope it helps.