Ruby on rails 3 简单的单选按钮(需要在标签内添加标签;

Ruby on rails 3 简单的单选按钮(需要在标签内添加标签;,ruby-on-rails-3,simple-form,Ruby On Rails 3,Simple Form,使用simple\u form\u for gem创建以下HTML的最佳方法是什么 <label> <input name="form-field-radio" type="radio" /> **<span class="lbl"> radio option 2</span>** </label> **单选方案2** 请注意,默认情况下,当我使用以下语句创建单选按钮时,不会创建上面的标记。如何将该标记添加到中 <

使用simple\u form\u for gem创建以下HTML的最佳方法是什么

<label>
   <input name="form-field-radio" type="radio" />
   **<span class="lbl"> radio option 2</span>**
</label>

**单选方案2**
请注意,默认情况下,当我使用以下语句创建单选按钮时,不会创建上面的标记。如何将该标记添加到中

<%= f.input :state, :collection => Project::STATES, :as => :radio_buttons %>
Project::STATES,:as=>:单选按钮%>
我也有类似的需求(在
中嵌入
)。这不是最干净的解决方案,但确实有效,我认为通过一些调整,它可以让您能够将输入和跨度嵌入标签中。以下修改导致:

<label>Name: 
  <span class="hint">this is a hint...</span>
</label>
# initializers/simple_form_custom.rb
module SimpleForm
  module Components
    module Labels

      def label_text
        if hint
          hint_text = %[<span class="hint">#{hint}</span>]
        else
          hint_text = ""
        end
        SimpleForm.label_text.call(raw_label_text, required_label_text, hint_text).strip.html_safe
      end

    end
  end
end
config.label_text = lambda { |label, required, hint| "#{label}: #{required} #{hint}" }