Skip to content

Commit

Permalink
Fix that label_tag doesn't take a symbol for a name. [#719 state:reso…
Browse files Browse the repository at this point in the history
…lved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information
DefV authored and lifo committed Jul 29, 2008
1 parent 2cf161a commit 7aaf168
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/helpers/form_tag_helper.rb
Expand Up @@ -129,7 +129,7 @@ def text_field_tag(name, value = nil, options = {})
# label_tag 'name', nil, :class => 'small_label'
# # => <label for="name" class="small_label">Name</label>
def label_tag(name, text = nil, options = {})
content_tag :label, text || name.humanize, { "for" => name }.update(options.stringify_keys)
content_tag :label, text || name.to_s.humanize, { "for" => name }.update(options.stringify_keys)
end

# Creates a hidden form input field used to transmit data that would be lost due to HTTP's statelessness or
Expand Down
6 changes: 6 additions & 0 deletions actionpack/test/template/form_tag_helper_test.rb
Expand Up @@ -190,6 +190,12 @@ def test_label_tag_without_text
assert_dom_equal expected, actual
end

def test_label_tag_with_symbol
actual = label_tag :title
expected = %(<label for="title">Title</label>)
assert_dom_equal expected, actual
end

def test_label_tag_with_text
actual = label_tag "title", "My Title"
expected = %(<label for="title">My Title</label>)
Expand Down

0 comments on commit 7aaf168

Please sign in to comment.