Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix options overwritten by super #17975

Merged
merged 1 commit into from
Dec 9, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 9 additions & 11 deletions actionview/lib/action_view/helpers/tags/search_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions actionview/lib/action_view/helpers/tags/text_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions actionview/test/template/form_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down