Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Retrieving i18n label text without the label tag wrapper #3671

derekprior opened this Issue Nov 17, 2011 · 6 comments


None yet
5 participants

derekprior commented Nov 17, 2011

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 <label> 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?


isaacsanders commented Apr 30, 2012

Any thoughts on this?


derekprior commented Apr 30, 2012

I still think this should be in the API. But having several pull requests to rails languishing, I'm not gung-ho about writing it if no one else cares.


rafaelfranca commented Jun 6, 2012

@derekprior I think this should be done. I'll be glad to review a pull request for this.

@derekprior I'd need that too. It would be particularly useful for index column headers.

Actually, I'd love to access label text helper even outside of a form (as index columns aren't forms).

Please, use the Ruby on Rails Core mailing list to ask for feedback about new features or changes in Rails, or the Ruby on Rails Talk mailing list for general questions and doubts about the framework. Lets try to keep the issues tracker for issues ;). Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment