method

label_tag

Importance_3
Ruby on Rails latest stable (v2.3.4) - 3 notes - Class: ActionView::Helpers::FormTagHelper
label_tag(name, text = nil, options = {}) public

Creates a label field

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>
Show source
Register or log in to add new notes.
September 18, 2008
1 thank

unobstrusive label tag

just use

    label_tag('a_a','a_a')

and it works, just not ment for pure decorative labels :)

September 17, 2008
0 thanks

removes underscores -> do not use for images etc

example

  #does not work
  label_tag('aa'+image_tag('x_x.gif'))
January 9, 2009 - (v2.2.1)
0 thanks

Dynamic labels

Code example

  <%=label_tag 'category_'+cat.title, cat.title%>