需要SimpleForm自定义单选按钮结构

时间:2015-08-12 12:53:05

标签: ruby-on-rails ruby-on-rails-4 simple-form

需要使用simple_form_for创建以下html结构(或类似):

   <fieldset id="burn0" class="burn">
      <ledgend>BURND</ledgend>
      <span class="custom-radio">
        <input name="entries[8488][burn_id]" id="entries_8488_burn_id_1" value="1" class="custom-radio" type="radio">
        <label class="custom-radio" for="entries_8488_burn_id_1"><span></span>Test 1</label>
        <input name="entries[8488][burn_id]" id="entries_8488_burn_id_2" value="2" class="custom-radio" type="radio">
        <label class="custom-radio" for="entries_8488_burn_id_2"><span></span>Test 2</label>
        <input name="entries[8488][burn_id]" id="entries_8488_burn_id_3" value="3" class="custom-radio" type="radio">
        <label class="custom-radio" for="entries_8488_burn_id_3"><span></span>Test 3</label>
        <input name="entries[8488][burn_id]" id="entries_8488_burn_id_4" value="4" class="custom-radio" checked="checked" type="radio">
        <label class="custom-radio" for="entries_8488_burn_id_4"><span></span>Test 4</label>
      </span>
    </fieldset>

我已经尝试了几种方法来做到这一点,例如。

<%= f.input :lang,
      collection: [[1, 'de'] ,[2, 'fr'],[3, 'it'],[4, 'en']],
      label_method: :last,
      value_method: :first,
      as: :radio_buttons,
      input_html: {class:  'custom-radio'},
      label_html: {class:  'custom-radio'},
      wrapper_html: {class: 'custom-radio'} %>

 <%= f.collection_radio_buttons :lang,
     [[1, 'de'] ,[2, 'fr'],[3, 'it'],[4, 'en']],
     :first,
     :last,
     label_method: "Language",
     input_html: { class: "custom-radio" },
     wrapper_html: {class: "custom-radio"} %>

但是这些似乎都没有足够的灵活性来实际为我的自定义单选按钮吐出所需的html结构。

文档实际上并不是那么简单。

0 个答案:

没有答案