提交 112274eb 编写于 作者: J Jose Añasco

Fix options overwritten by super

上级 8e529543
......@@ -3,20 +3,18 @@ module Helpers
module Tags # :nodoc:
class SearchField < TextField # :nodoc:
def render
options = @options.stringify_keys
if options["autosave"]
if options["autosave"] == true
options["autosave"] = request.host.split(".").reverse.join(".")
super do |options|
if options["autosave"]
if options["autosave"] == true
options["autosave"] = request.host.split(".").reverse.join(".")
end
options["results"] ||= 10
end
options["results"] ||= 10
end
if options["onsearch"]
options["incremental"] = true unless options.has_key?("incremental")
if options["onsearch"]
options["incremental"] = true unless options.has_key?("incremental")
end
end
super
end
end
end
......
......@@ -11,6 +11,7 @@ def render
options["size"] = options["maxlength"] unless options.key?("size")
options["type"] ||= field_type
options["value"] = options.fetch("value") { value_before_type_cast(object) } unless field_type == "file"
yield options if block_given?
add_default_name_and_id(options)
tag("input", options)
end
......
......@@ -928,6 +928,11 @@ def test_search_field
assert_dom_equal(expected, search_field("contact", "notes_query"))
end
def test_search_field_with_onsearch_value
expected = %{<input onsearch="true" type="search" name="contact[notes_query]" id="contact_notes_query" incremental="true" />}
assert_dom_equal(expected, search_field("contact", "notes_query", onsearch: true))
end
def test_telephone_field
expected = %{<input id="user_cell" name="user[cell]" type="tel" />}
assert_dom_equal(expected, telephone_field("user", "cell"))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册