我不明白你將如何使用引導開關腳本的文本字段。儘管如此,有些人可能會在這裏以與標題中所提問題相同的問題結束。
您可以簡單地複製引導包裝,並添加所需的類:
config.wrappers :bootstrap_switch, tag: 'div', class: "control-group", error_class: 'error', boolean_style: :inline do |b|
b.use :html5
b.use :placeholder
b.use :label
b.wrapper tag: 'div', class: 'controls' do |ba|
ba.wrapper "switch", tag: 'div', class: 'switch' do |s|
s.use :input
end
ba.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
end
這將創建一個具有一流的「開關」(因此由腳本風格化)嵌套式div。這個內部包裝有命名空間「開關」,它使我們能夠設置一些選項:
f.input :inputField, :wrapper => :bootstrap_switch, :switch_html => { :data => { on: "success", on_label: "<i class='icon-ok icon-white'></i>", off: "warning", off_label: "<i class='icon-remove'></i>" } }
你想使用包裝引導程序開關和生成的HTML。我發現[form-horizontal original bootstrap](http://twitter.github.io/bootstrap/base-css.html#form-horizontal)和[form-horizontal bootstrap switch](http:// www。 larentis.eu/switch/#form-horizontal) –