小编Pet*_*rZD的帖子

Simple_form:如何更改输入的包装器类?(不是wrapper_html效果)

使用simple_form和Bootstrap时遇到问题3.关于输入的包装器标签.显示以下代码:

查看代码(带haml)

= simple_form_for @refer_email_form, url: create_refer_message_path, html: { class: "form-horizontal" } do |f|
  = f.input :to, label_html: { class: "col-sm-2" }
  = f.input :subject, label_html: { class: "col-sm-2" }
Run Code Online (Sandbox Code Playgroud)

配置/ simple_form_bootstrap.rb

SimpleForm.setup do |config|
  config.input_class = "form-control"

  config.wrappers :bootstrap, tag: 'div', class: 'form-group', error_class: 'error' do |b|
    b.use :html5
    b.use :placeholder
    b.use :label, class: "control-label"
    # b.wrapper tag: 'div', class: "col-sm-6" do |ba|
    b.wrapper tag: 'div' do |ba|
      ba.use :input
      ba.use :error, wrap_with: { tag: 'span', class: 'help-inline' …
Run Code Online (Sandbox Code Playgroud)

simple-form twitter-bootstrap ruby-on-rails-4

12
推荐指数
1
解决办法
8190
查看次数