This project is archived and is in readonly mode.
Let label helpers accept blocks
Reported by Stephen Celis | January 3rd, 2010 @ 05:25 PM | in 3.0.2
Label helpers should process blocks in addition to their defaults because it's common for their content to have more complex markup than text.
This, for example,
<%= f.label :terms, "<span>Accept #{link_to 'Terms', terms_path}</span>" %>
Is much easier to read in a block
<% f.label :terms do %>
<span>Accept <%= link_to "Terms", terms_path %></span>
<% end %>
An additional perk: in our editors, the HTML markup won't be lost in Ruby string syntax highlighting.
Patch with tests in comments.
Comments and changes to this ticket
-
Stephen Celis January 3rd, 2010 @ 05:26 PM
- Tag set to action_view, block, form_helper, form_tag_helper, label, label_tag, to_label_tag
-
Stephen Celis January 3rd, 2010 @ 05:27 PM
- Tag changed from action_view, block, form_helper, form_tag_helper, label, label_tag, to_label_tag to action_view, block, form_helper, form_tag_helper, label, label_tag, patch, to_label_tag
-
Stephen Celis January 3rd, 2010 @ 06:05 PM
- no changes were found...
-
Chris Hapgood January 5th, 2010 @ 01:36 PM
Double bonus for this enhancement -thanks Stephen. I see that you have also made the "name" attribute optional -fantastic. Now one can implicitly apply a label to the enclosed input without having to worry about id matching with the 'for' attribute:
label_tag nil, "Your Name" do
text_field_tag 'name' endIMO, the signature of #label_tag (and #label) should evolve to better support this practice as it reduces the need to keep DOM ids in sync between the input and the label. Perhaps by counting args to label_tag and assuming a single string argument is a contextual label.
-
Stefano Diem February 5th, 2010 @ 12:49 PM
Pretty cool!
I use a lot of labels with images inside, especially on radiobuttons and checkboxes to be able to check the corresponding field without having to resort to javascript, and things usually get very messy having to add them inside the label and label_tag methods. So this patch is something i'm realy looking for! Do you need help with anything?
-
Stephen Celis February 8th, 2010 @ 02:55 PM
Biggest help would be to test the patch out and get others to do so.
Once a few people approve, we can mark this "confirmed."
-
José Valim May 5th, 2010 @ 07:48 PM
- Milestone cleared.
- Assigned user set to José Valim
-
Adrian Sanchez May 5th, 2010 @ 09:34 PM
It's a good feature,
I try, run the test and work fine.
Thank you Stephen
-
Dan Pickett May 9th, 2010 @ 06:52 PM
- Tag changed from action_view, block, form_helper, form_tag_helper, label, label_tag, patch, to_label_tag to action_view, block, bugmash, form_helper, form_tag_helper, label, label_tag, patch, to_label_tag
-
Stephen Celis May 14th, 2010 @ 08:29 PM
- Tag changed from action_view, block, bugmash, form_helper, form_tag_helper, label, label_tag, patch, to_label_tag to action_view, block, bugmash, form_helper, form_tag_helper, label, label_tag, patch, to_label_tag, verified
-
Repository May 15th, 2010 @ 08:51 AM
- State changed from new to resolved
(from [d18a2742e01d195eb2d228207062aff49f7eb854]) Improve previous patch a bit [#3645 state:resolved] http://github.com/rails/rails/commit/d18a2742e01d195eb2d228207062af...
-
Jeremy Kemper October 15th, 2010 @ 11:01 PM
- Milestone set to 3.0.2
- Importance changed from to Low
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 3645 Let label helpers accept blocks (from [d18a2742e01d195eb2d228207062aff49f7eb854]) Improve...