Label tag wrapping Input tag in radio buttons (Simple_form)

时间秒杀一切 提交于 2019-12-25 02:51:59

问题


I'm using the gem simple_form with Rails to create my forms.

I want to create radio_buttons that have the input tag wrapped in the label tag, for example:

<label>
  <input id="optionsRadios2" name="optionsRadios" value="option2" type="radio"/>
  Option one
</label>

but what I get is this:

<input id="optionsRadios" name="optionsRadios" value="option2" type="radio"/>
<label for="optionsRadios1"> Option one</label>

Is there a way to create the input tag inside label tag using wrappers? how?

I could not find any ways by now (here is the doc: http://www.rubydoc.info/github/plataformatec/simple_form/master/SimpleForm/FormBuilder:collection_radio_buttons)

Thanks for any help!


回答1:


Try this:

<%= f.collection_radio_buttons :options, [[true, 'Yes'] ,[false, 'No']], :optionsRadios1, :optionsRadios2, {:item_wrapper_class => 'inline'}, {:class => "radio-inline" }%> 


来源:https://stackoverflow.com/questions/30618863/label-tag-wrapping-input-tag-in-radio-buttons-simple-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!