我不知道为什么它不像示例那样重复。当我将以下代码放入此表单时:
<%= 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 添加了初始化程序?这个初始值设定项设置应该用于输出 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/