我有一个用formtastic构建的表单,代码是
<%= semantic_form_for @plan, :html => { :class => "form-horizontal" } do |form|%>
<%= form.input :name %>
[..some inputs here...]
<%= form.buttons%>
<%end%>但是表单并没有得到" form -horizontal“类,生成的代码是
<form id="new_plan" class="formtastic plan" novalidate="novalidate" method="post" action="/plans" accept-charset="UTF-8">
[...inputs/actions...]
</form>为什么?
我使用的是formtastic 2.1,gemfile:
gem 'formtastic', :git => 'https://github.com/justinfrench/formtastic.git', :branch => "2.1-stable"提前感谢
发布于 2012-02-07 23:50:16
您需要将html选项包装在另一个散列中。
<%= semantic_form_for @plan, {:html => { :class => "form-horizontal" }} do |form|%>这看起来确实很奇怪,但我以前遇到过这个问题,上面的方法解决了它。
希望能有所帮助。
https://stackoverflow.com/questions/9178794
复制相似问题