2012-02-07 63 views
1

我與formtastic建立了一個表格,代碼Ruby on Rails的 - formtastic - 窗體類

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

但形式沒有得到一流「的形式橫」,生成的代碼是

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

爲什麼?

我使用formtastic 2.1的Gemfile:提前

回答

4

你需要用另一種散列你的HTML選項

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

感謝

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

它似乎劑量奇怪,但我之前有過這個問題,上面解決了它。

希望它有幫助。

+0

謝謝,它的工作 – qwertoyo 2012-02-07 15:56:49

+1

太好了。如果它幫助你,你會介意接受嗎?謝謝。 – 2012-02-07 15:59:25

+0

當然,對不起,但這是我的第一個問題。 – qwertoyo 2012-02-07 18:59:14