Changeset 8685
- Timestamp:
- 01/21/08 21:08:28 (4 months ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_view/helpers/form_tag_helper.rb (modified) (1 diff)
- trunk/actionpack/test/template/form_tag_helper_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r8684 r8685 1 1 *SVN* 2 3 * Add label_tag helper for generating elements. #10802 [DefV] 2 4 3 5 * Introduce TemplateFinder to handle view paths and lookups. #10800 [Pratik Naik] trunk/actionpack/lib/action_view/helpers/form_tag_helper.rb
r8203 r8685 113 113 def text_field_tag(name, value = nil, options = {}) 114 114 tag :input, { "type" => "text", "name" => name, "id" => name, "value" => value }.update(options.stringify_keys) 115 end 116 117 # Creates a label field 118 # 119 # ==== Options 120 # * Creates standard HTML attributes for the tag. 121 # 122 # ==== Examples 123 # label_tag 'name' 124 # # => <label for="name">Name</label> 125 # 126 # label_tag 'name', 'Your name' 127 # # => <label for="name">Your Name</label> 128 # 129 # label_tag 'name', nil, :class => 'small_label' 130 # # => <label for="name" class="small_label">Name</label> 131 def label_tag(name, text = nil, options = {}) 132 content_tag :label, text || name.humanize, { "for" => name }.update(options.stringify_keys) 115 133 end 116 134 trunk/actionpack/test/template/form_tag_helper_test.rb
r8564 r8685 189 189 end 190 190 191 def test_label_tag_without_text 192 actual = label_tag "title" 193 expected = %(<label for="title">Title</label>) 194 assert_dom_equal expected, actual 195 end 196 197 def test_label_tag_with_text 198 actual = label_tag "title", "My Title" 199 expected = %(<label for="title">My Title</label>) 200 assert_dom_equal expected, actual 201 end 202 203 def test_label_tag_class_string 204 actual = label_tag "title", "My Title", "class" => "small_label" 205 expected = %(<label for="title" class="small_label">My Title</label>) 206 assert_dom_equal expected, actual 207 end 208 191 209 def test_boolean_optios 192 210 assert_dom_equal %(<input checked="checked" disabled="disabled" id="admin" name="admin" readonly="readonly" type="checkbox" value="1" />), check_box_tag("admin", 1, true, 'disabled' => true, :readonly => "yes")