提交 8946804b 编写于 作者: J Jamis Buck

Make xyz_tag(..., :id => "foo") work again


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2535 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 6fe5f65d
...@@ -47,7 +47,7 @@ def end_form_tag ...@@ -47,7 +47,7 @@ def end_form_tag
# Options: # Options:
# * <tt>:multiple</tt> - If set to true the selection will allow multiple choices. # * <tt>:multiple</tt> - If set to true the selection will allow multiple choices.
def select_tag(name, option_tags = nil, options = {}) def select_tag(name, option_tags = nil, options = {})
content_tag("select", option_tags, { "name" => name, "id" => name }.update(options)) content_tag("select", option_tags, { "name" => name, "id" => name }.update(options.stringify_keys))
end end
# Creates a standard text field. # Creates a standard text field.
...@@ -59,7 +59,7 @@ def select_tag(name, option_tags = nil, options = {}) ...@@ -59,7 +59,7 @@ def select_tag(name, option_tags = nil, options = {})
# #
# A hash of standard HTML options for the tag. # A hash of standard HTML options for the tag.
def text_field_tag(name, value = nil, options = {}) def text_field_tag(name, value = nil, options = {})
tag("input", { "type" => "text", "name" => name, "id" => name, "value" => value }.update(options)) tag("input", { "type" => "text", "name" => name, "id" => name, "value" => value }.update(options.stringify_keys))
end end
# Creates a hidden field. # Creates a hidden field.
...@@ -103,33 +103,33 @@ def text_area_tag(name, content = nil, options = {}) ...@@ -103,33 +103,33 @@ def text_area_tag(name, content = nil, options = {})
options.delete("size") options.delete("size")
end end
content_tag("textarea", content, { "name" => name, "id" => name }.update(options)) content_tag("textarea", content, { "name" => name, "id" => name }.update(options.stringify_keys))
end end
# Creates a check box. # Creates a check box.
def check_box_tag(name, value = "1", checked = false, options = {}) def check_box_tag(name, value = "1", checked = false, options = {})
html_options = { "type" => "checkbox", "name" => name, "id" => name, "value" => value }.update(options) html_options = { "type" => "checkbox", "name" => name, "id" => name, "value" => value }.update(options.stringify_keys)
html_options["checked"] = "checked" if checked html_options["checked"] = "checked" if checked
tag("input", html_options) tag("input", html_options)
end end
# Creates a radio button. # Creates a radio button.
def radio_button_tag(name, value, checked = false, options = {}) def radio_button_tag(name, value, checked = false, options = {})
html_options = { "type" => "radio", "name" => name, "id" => name, "value" => value }.update(options) html_options = { "type" => "radio", "name" => name, "id" => name, "value" => value }.update(options.stringify_keys)
html_options["checked"] = "checked" if checked html_options["checked"] = "checked" if checked
tag("input", html_options) tag("input", html_options)
end end
# Creates a submit button with the text <tt>value</tt> as the caption. # Creates a submit button with the text <tt>value</tt> as the caption.
def submit_tag(value = "Save changes", options = {}) def submit_tag(value = "Save changes", options = {})
tag("input", { "type" => "submit", "name" => "commit", "value" => value }.update(options)) tag("input", { "type" => "submit", "name" => "commit", "value" => value }.update(options.stringify_keys))
end end
# Displays an image which when clicked will submit the form. # Displays an image which when clicked will submit the form.
# #
# <tt>source</tt> is passed to AssetTagHelper#image_path # <tt>source</tt> is passed to AssetTagHelper#image_path
def image_submit_tag(source, options = {}) def image_submit_tag(source, options = {})
tag("input", { "type" => "image", "src" => image_path(source) }.update(options)) tag("input", { "type" => "image", "src" => image_path(source) }.update(options.stringify_keys))
end end
end end
end end
......
...@@ -87,5 +87,11 @@ def test_boolean_optios ...@@ -87,5 +87,11 @@ def test_boolean_optios
assert_dom_equal %(<select id="people" multiple="multiple" name="people"><option>david</option></select>), select_tag("people", "<option>david</option>", :multiple => true) assert_dom_equal %(<select id="people" multiple="multiple" name="people"><option>david</option></select>), select_tag("people", "<option>david</option>", :multiple => true)
assert_dom_equal %(<select id="people" name="people"><option>david</option></select>), select_tag("people", "<option>david</option>", :multiple => nil) assert_dom_equal %(<select id="people" name="people"><option>david</option></select>), select_tag("people", "<option>david</option>", :multiple => nil)
end end
def test_stringify_symbol_keys
actual = text_field_tag "title", "Hello!", :id => "admin"
expected = %(<input id="admin" name="title" type="text" value="Hello!" />)
assert_dom_equal expected, actual
end
end end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册