How can I put a <span>
tag inside an f.label
tag?
<%= f.label :test %>
Requested output:
<label for="test">test<span>*</span></label>
Label accepts a block, so you can do this:
<%= f.label :test do %>
<span>*</span>
<%end%>
You need to tell rails that the string you're giving it does not need to be sanitized. Use String#html_safe
.
<%= f.label :test, "test<span>*</span>".html_safe %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With