【问题标题】:simple_form bootstrap inputsimple_form 引导输入
【发布时间】:2017-05-15 14:39:21
【问题描述】:

我对 html 和 erb 还很陌生,我在使用自定义 simple_form 时遇到了问题。

我需要翻译这个 html.erb 输入

<%= object.input :attribute, label: 'mylabel' %>

到这个html输入类型

<label class="col-sm-3 control-label">mylabel</label>
<div class="col-sm-9">
  <input class="form-control">
</div>

【问题讨论】:

标签: html ruby-on-rails twitter-bootstrap


【解决方案1】:

您需要将:horizontal_forml 包装器和'form-horizontal' 类添加到form

<%= simple_form_for @post, html: { class: 'form-horizontal' }, wrapper: :horizontal_form do |f| %>
  <%= f.input :attribute, label: 'mylabel' %>
<% end %>

【讨论】:

  • 这样哇。这不是我想要做的,但实际上要好得多,谢谢。
猜你喜欢
  • 2015-05-21
  • 1970-01-01
  • 2013-01-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-14
  • 1970-01-01
相关资源
最近更新 更多