有谁知道如何将 simple_form 使用的类从“控件”更改为“表单控件”。这是在 Bootstrap 3 中所做的更改。我知道 config/initializers/simple_form.rb 和 config/initializers/simple_form_bootstrap.rb 中有很多选项,但我找不到我需要的。
config.wrappers :bootstrap, :tag => 'div', :class => 'control-group', :error_ class => 'error' do |b|
b.use :html5
b.use :placeholder
b.use :label
b.wrapper :tag => 'div', :class => 'controls' do |ba|
ba.use :input
ba.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
ba.use :hint, :wrap_with => { :tag => 'p', :class => 'help-block' }
end
end
在上面你可以将'control-group'换成'form-group',但我看不出有办法改变输入标签的类。
最佳答案
在较新的 simple_form 版本中,您可以使用一个新的全局配置:
config.input_class = "form-control"
您需要 gem 版本 >3.0.0,它取决于 rails >4.0.0,或即将发布的 2.2 版本。您现在可以使用 github 上的 v2.2 分支。
见 https://github.com/plataformatec/simple_form/blob/v2.2/CHANGELOG.md
关于ruby-on-rails - 在 bootstrap 3 中使用 simple_form,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18403372/