2
我想創建一個simple_form包裝匹配Bootstrap 4的堆疊複選框/收音機。自定義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>