rails/rails — pull request #16488 by agrobbin (2014-08-13 04:08:07+00:00)
Title: Provide a builder for form labels to customize wrapping around I18n content

The problem I'm trying to solve is when you have a `label` that you also want to include an input inside of, but you also want to include the default I18n'd content for the label. Example:

```html+erb
<%= f.label :terms, class: "checkbox" do %>
<%= f.check_box :terms %>
<%= t("helpers.label.user.terms") %>
<% end %>
```

Unfortunately, this doesn't fall back to the other I18n values as a normal `f.label :terms` call would.

In comes the new builder, which behaves similarly to `collection_radio_buttons` and `collection_check_boxes`. The above can now be written like this:

```html+erb
<%= f.label :terms, class: "checkbox" do |b| %>
<%= f.check_box :terms %>
<%= b.text %>
<% end %>
```

It should still work if you don't want to use the yielded `builder` argument, so no backwards compatibility issues to worry about.