rails/rails — Issue #3671: Retrieving i18n label text without the label tag wrapper 
Author: derekprior
Created: 2011-11-17 22:47:25+00:00
State: open

Internationalizing form labels for object attributes is done by `FormBuilder.label`. It no label text is provided to the method, it does a couple of different i18n lookups (helpers.label... and active_record.attributes via human_attribute_name) followed finally by a call to humanize.

Unfortunately, this multistep process isn't exposed in the API anywhere that doesn't also wrap the results in a `` tag. Not anywhere I could find, anyway. When building a custom form builder I had a need to get just the text, without the wrapping tag. Re-implementing the multiple lookups seemed like a tenuous solution so I opted to call `label` and then strip the tag with gsub.

I'm willing to write something like `FormBuilder.label_text` that would expose this part of the API if that's something that actually has a chance of being pulled. Thoughts?