ruby-on-rails - Twitter Bootstrap : Simple_form not making horizontal form or correct HTML output?

标签 ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1 simple-form

我不知道为什么它不像示例那样重复。当我将以下代码放入此表单时:

<%= 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 %>

现在它看起来像这样:

enter image description here

当我希望它是这样的(这里的第一个例子: http://simple-form-bootstrap.plataformatec.com.br/articles/new )。

enter image description here

问题在于正在生成的 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 添加了初始化程序?这个初始值设定项设置应该用于输出 bootstrap html 的包装器

rails generate simple_form:install --bootstrap

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

关于ruby-on-rails - Twitter Bootstrap : Simple_form not making horizontal form or correct HTML output?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9311120/

相关文章:

mysql - 对打乱的 ActiveRecord 查询进行分页

ruby-on-rails - ruby on rails 中的下拉列表表单验证警报

mysql - Ruby On Rails 检索 mysql 数据库数据 'a' 不同的 'b'

ruby-on-rails - 开始使用 rails 6 : how to start a blank new rails 6 application

ruby-on-rails - 通过 get in rails 传递参数数组

ruby-on-rails - 如何在 has_many_through 关系中保存额外字段

ruby-on-rails-3 - 无法安装 rmagick、ruby 1.9、rails 3、windows

ruby-on-rails - Rails 3- Will_Paginate - 使分页链接更像 GMAIL

authentication - Mongoid 和 has_secure_password

ruby-on-rails-3.1 - 带有 mysql2 适配器的 Rails Rubber gem - 由于用户错误而拒绝访问