【发布时间】:2018-02-14 06:10:35
【问题描述】:
我正在尝试创建一个 simple_form 包装器来匹配 Bootstrap 4 的堆叠复选框/收音机。
这是我想要复制的 HTML 结构,由 Boostrap's docs 提供:
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" value="">
Option one is this and that—be sure to include why it's great
</label>
</div>
<div class="form-check disabled">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" value="" disabled>
Option two is disabled
</label>
</div>
这是我的 simple_form 包装器当前所在的位置:
config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
b.use :html5
b.optional :readonly
b.use :label
b.use :input, class: "form-check-input"
b.use :error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
end
这是它当前输出的 HTML 结构:
<span class="checkbox">
<label for="">
<input class="form-check-input check_boxes optional" type="checkbox" value="" name="" id="">
Text for checkbox goes here
</label>
</span>
【问题讨论】:
标签: html ruby-on-rails twitter-bootstrap forms simple-form