simple_form をhttp://semantic-ui.com/構文で機能させるために、このラジオ ボタンの HTML シーケンスを simple_form で再現したいと思います。
<div class="grouped inline fields">
<div class="field">
<div class="ui radio checkbox">
<input type="radio" name="fruit" checked="">
<label>Apples</label>
</div>
</div>
<div class="field">
<div class="ui radio checkbox">
<input type="radio" name="fruit">
<label>Oranges</label>
</div>
</div>
<div class="field">
<div class="ui radio checkbox">
<input type="radio" name="fruit">
<label>Pears</label>
</div>
</div>
<div class="field">
<div class="ui radio checkbox">
<input type="radio" name="fruit">
<label>Grapefruit</label>
</div>
</div>
</div>
そこで、カスタムラッパーを用意しました:
config.wrappers :semantic_radios, tag: 'div', class: "grouped fields", error_class: 'error', hint_class: 'with_hint' do |b|
b.use :html5
b.use :label
b.use :input
end
いくつかのオプションを設定します:
config.item_wrapper_tag = :div
config.item_wrapper_class = 'ui radio checkbox'
そして、私のフォームでこのコードを呼び出します:
=f.input :child_care_type, collection: [["option 1", 1],["option 2", 2]], as: :radio_buttons, wrapper: :semantic_radios
div.field カプセル化をカスタマイズする場所がわかりません:
<div class="field">
<div class="ui radio checkbox">
<input type="radio" name="fruit" checked="">
<label>Apples</label>
</div>
</div>
私のコードはこれをレンダリングするだけです:
<div class="ui radio checkbox">
<input type="radio" name="fruit" checked="">
<label>Apples</label>
</div>
手伝って頂けますか ?コレクションのラッパーのカスタマイズが見つかりませんでした:s