Permalink
Browse files

Merge pull request #2095 from dgeb/issue-2094

Fixes overriding of options[:html][:remote] in form_for() (Issue #2094)
  • Loading branch information...
2 parents d482cf8 + 455e321 commit ef89a70540f09e4c454e05a3c9ae0824884ad967 @tenderlove tenderlove committed Jul 26, 2011
Showing with 18 additions and 1 deletion.
  1. +1 −1 actionpack/lib/action_view/helpers/form_helper.rb
  2. +17 −0 actionpack/test/template/form_helper_test.rb
@@ -365,7 +365,7 @@ def form_for(record, options = {}, &proc)
apply_form_for_options!(record, options)
end
- options[:html][:remote] = options.delete(:remote)
+ options[:html][:remote] = options.delete(:remote) if options.has_key?(:remote)
options[:html][:method] = options.delete(:method) if options.has_key?(:method)
options[:html][:authenticity_token] = options.delete(:authenticity_token)
@@ -791,6 +791,23 @@ def test_form_for_with_remote
assert_dom_equal expected, output_buffer
end
+ def test_form_for_with_remote_in_html
+ form_for(@post, :url => '/', :html => { :remote => true, :id => 'create-post', :method => :put }) do |f|
+ concat f.text_field(:title)
+ concat f.text_area(:body)
+ concat f.check_box(:secret)
+ end
+
+ expected = whole_form("/", "create-post", "edit_post", :method => "put", :remote => true) do
+ "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
+ "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
+ "<input name='post[secret]' type='hidden' value='0' />" +
+ "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />"
+ end
+
+ assert_dom_equal expected, output_buffer
+ end
+
def test_form_for_with_remote_without_html
@post.persisted = false
form_for(@post, :remote => true) do |f|

0 comments on commit ef89a70

Please sign in to comment.