public Method

FormTagHelper.label_tag(name, text = nil, options = {})

Contents:

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">Name</label>

Source Code

# File action_view/helpers/form_tag_helper.rb, line 131
def label_tag(name, text = nil, options = {})
  content_tag :label, text || name.humanize, { "for" => name }.update(options.stringify_keys)
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.