Label Helper Makes It Into Edge Rails
Changeset 7541 just made me a happy man. The first thing that I do with every rails I app I work on is install Rick Olson’s label helper plugin. With the aforementioned changeset though, a helper for making form labels has been added to rails core. This will save me time on each rails app which means time to market is now around 4 minutes. :)
A Few Examples
label(:post, :title) #=> <label for="post_title">Title</label> label(:post, :title, "A short title") #=> <label for="post_title">A short title</label> label(:post, :title, "A short title", :class => "title_label") #=> <label for="post_title" class="title_label">A short title</label>
I do find it odd that they didn’t add label’s partner, label_tag. All the other form helpers (text_field => text_field_tag, select => select_tag, etc.) have an _tag companion method. Maybe I missed it somewhere.
For those that don’t use labels, you should. They are good for accessibility and also when clicked, highlight the associated field element, if you code them correctly.