method
label_tag
v8.1.1 -
Show latest stable
-
4 notes -
Class: ActionView::Helpers::FormTagHelper
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3 (0)
- 2.1.0 (0)
- 2.2.1 (3)
- 2.3.8 (0)
- 3.0.0 (27)
- 3.0.9 (-38)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (-5)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- 7.2.3 (0)
- 8.0.0 (0)
- 8.1.1 (0)
- What's this?
label_tag(name = nil, content_or_options = nil, options = nil, &block)
public
Creates a label element. Accepts a block.
Options
-
Creates standard HTML attributes for the tag.
Examples
label_tag 'name' # => <label for="name">Name</label> label_tag 'name', 'Your name' # => <label for="name">Your name</label> label_tag 'name', nil, class: 'small_label' # => <label for="name" class="small_label">Name</label>
Register or
log in
to add new notes.
grosser -
September 18, 2008
grosser -
September 17, 2008
bansalakhil -
January 9, 2009 - (v2.2.1)
taimoorchangaiz -
June 5, 2013 - (v2.0.3 - v3.2.13)
1 thank
unobstrusive label tag
just use
label_tag('a_a','a_a')
and it works, just not ment for pure decorative labels :)
0 thanks
removes underscores -> do not use for images etc
example
#does not work label_tag('aa'+image_tag('x_x.gif'))
0 thanks
0 thanks
Html inside Lable tag
I need this
<label> Show <select size="1" name="dyntable_length" aria-controls="dyntable"> <option value="10" selected="selected">10</option> <option value="25">25</option> <option value="50">50</option> <option value="100">100</option> </select> entries </label>
I made a helper method:
def entries_lablel() label_tag '' do concat 'Show ' concat content_tag(:select, options_for_select([10, 25, 50, 100]), {name: 'dyntable_length', size: 1} ) concat ' entries' end end
and In my html.erb file I called it
<%= entries_lablel %>
You can pass paramateres to make it more generic also You can add multiple select elements or any other element using the same

