尝试将 Simple_form gem 的集合收音机的包装器转换为
我正在使用 simple_form gem (https://github.com/plataformatec/simple_form) 来帮助我的应用程序中的表单。但我想显示 li 标签中的许多单选按钮。 Simple_form 现在为每个单选按钮生成 span 包装标签。像这样:
<%= t.input :arrives_in, :collection => [1,2,3,4], :as => :radio %>
#=> <span><input type='radio'><label>1</label></span>
有什么方法可以让它将输入和标签部分包装在 li 而不是 span 中?
谢谢你!
I am using the simple_form gem (https://github.com/plataformatec/simple_form) to help out the forms in my app. But I'd like to display the many radio buttons I've got here in li tag. Simple_form now generates span wrapper tag for each radio buttons. Like this:
<%= t.input :arrives_in, :collection => [1,2,3,4], :as => :radio %>
#=> <span><input type='radio'><label>1</label></span>
any way I can have it wrap the input and label part in an li instead of span?
Thank YOU!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将
:item_wrapper_tag
传递给您的输入,如下所示:您还可以传递
:collection_wrapper_tag
选项来更改所有无线电输入的包装器,如下所示:You can pass
:item_wrapper_tag
to you input like this:You can also, pass the
:collection_wrapper_tag
option to change the wrapper of all radio inputs like this:尝试了接受的答案。它将子弹很好地粘在我的单选按钮前面,但它仍然没有显示内联。我刚刚用 CSS 做到了。我在按钮和标签周围打了一个带有 class="radio-buttons" 的 div 。然后我将其添加到我的样式表(SASS)中:
这将使单选按钮内联在所有框架上,尽管这经过调整以看起来最适合 Zurb Foundation。 ;)
Tried the accepted answer. It stuck bullets in front of my radio buttons fine, but it still didn't display inline. I just did it with CSS. I slapped a div with class="radio-buttons" around the buttons and label. Then I added this to my style sheet (SASS):
This will make the radio buttons inline on ALL frameworks, though this is tweaked to look the best for Zurb Foundation. ;)