Nest input inside f.label ( rails form generation )

前端 未结 5 423
广开言路
广开言路 2020-12-28 17:22

I want to use the f.label method to create my form element labels, however - i want to have the form element nested inside the label. Is this possible?

-- From W3C --

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-28 17:46

    Use this little workaround

    <%= f.label(:content, "#{f.check_box(:allow_posts)}\n#{:content}\n".html_safe, :class => "checkbox") %>
    

    will give you this

    content

提交回复
热议问题