simple_form collection_Radio_buttons生成额外标签

Phi*_*899 1 ruby ruby-on-rails simple-form ruby-on-rails-4 simple-form-for

我有以下Ruby:

<%= simple_form_for @answer, url: presentation_survey_path(@presentation) do |f| %>
                <%= f.collection_radio_buttons :option_id, @question.options_array, :first, :last, {label: false} do |b| %>
    <div class="col-sm-4">
        <%= b.label(class: 'btn btn-large', style: 'margin-right: 20px; margin-left: 20px;') {b.radio_button(id: b.object.last, class: 'answer-input', style: 'display: none;') + b.text } %>
    </div>
<% end %>
Run Code Online (Sandbox Code Playgroud)

它正确生成html,除了它生成两个标签:

<span>
    <label for="answer_option_id_15">
        <div class="col-sm-4">
            <label class="btn btn-large" for="answer_option_id_15" style="margin-right: 20px; margin-left: 20px;">
                <input class="answer-input" id="Way too many" name="answer[option_id]" style="display: none;" type="radio" value="15" />
            Way too many
            </label>
        </div>
    </label>
</span>
Run Code Online (Sandbox Code Playgroud)

由于某种原因,它正在制造第一个标签.我只想保留第二个.标签:false不起作用.如何摆脱第一个标签?

Ami*_*itA 7

根据文件:

对于复选框和单选按钮,您可以从默认值中删除标签更改boolean_style:嵌套为:inline.

此外,代码中还记录了simple_form一些选项collection_radio_buttons:

# Collection radio accepts some extra options:
#
#   * checked  => the value that should be checked initially.
#
#   * disabled => the value or values that should be disabled. Accepts a single
#                 item or an array of items.
#
#   * collection_wrapper_tag   => the tag to wrap the entire collection.
#
#   * collection_wrapper_class => the CSS class to use for collection_wrapper_tag
#
#   * item_wrapper_tag         => the tag to wrap each item in the collection.
#
#   * item_wrapper_class       => the CSS class to use for item_wrapper_tag
#
#   * a block                  => to generate the label + radio or any other component.
Run Code Online (Sandbox Code Playgroud)

在我的情况下设置item_wrapper_tagfalseboolean_style:inline的伎俩,如:

<%= f.collection_radio_buttons :option_id, @question.options_array, :first, :last, boolean_style: :inline, item_wrapper_tag: false do |b| %>
Run Code Online (Sandbox Code Playgroud)