ruby-on-rails – Twitter-Bootstrap:Simple_form不使水平形式或正确的HTML输出?

我不知道为什么它不像例子那样重复.当我把以下代码放在这个表单中:

<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :class => "form-horizontal" } ) do |f| %>
<%= f.input :user_name, :input_html => { :class => "span3" }, :hint => "just letters and numbers please." %>
<% end %>

现在看起来像这样:

当我想要这样(这里的第一个例子:http://simple-form-bootstrap.plataformatec.com.br/articles/new).

问题在于生成的HTML.我的HTML是:

<div class="input string optional">
 <label for="user_user_name" class="string optional"> User name</label>
  <input type="text" size="50" name="user[user_name]" maxlength="25" id="user_user_name" class="string optional span3">
   <span class="hint">no spaces or special characters, just letters and numbers please</span>
</div>

和Simple_forms HTML:

<div class="control-group string required">
 <label for="article_name" class="string required">
  <abbr title="required">*</abbr> Name
 </label>
  <div class="controls">
   <input type="text" size="50" name="article[name]" id="article_name" class="string required span6">
    <p class="help-block">add your article title here</p>
  </div>
</div>

完全不同.我在想Bootstrap生成器不会生成?你怎么看?我该怎么办?

资源

https://github.com/plataformatec/simple_form

https://github.com/rafaelfranca/simple_form-bootstrap

http://simple-form-bootstrap.plataformatec.com.br/

您是否为simple_form添加了初始化程序?这个初始化器设置应该用于输出引导html的包装器

rails generate simple_form:install --bootstrap

请注意,这只适用于simple_form 2!

翻译自:https://stackoverflow.com/questions/9311120/twitter-bootstrap-simple-form-not-making-horizontal-form-or-correct-html-output

转载注明原文:ruby-on-rails – Twitter-Bootstrap:Simple_form不使水平形式或正确的HTML输出?