Rails, insert span tag in form_for label custom text

html, ruby-on-rails

Solution

As most of the Form helpers, you can pass a do/block instead of the name argument:

<%= f.label :address do %>
  Address<span class="required">*</span>
<% end %>

Works with `link_to` also:

<%= link_to root_path do %>
  <div>Hey!</div>
<% end %>

Problem

My problem is I wanted to insert a `<span>` tag in `form_for label` custom text. In normal html code, it would be like this: `<label>Address<span class="required">*</span></label>` but it Rails, how would I insert it in here: `<%= f.label :address, "Address" %>` It's just an indication for required fields.

Original source