aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorStephen St. Martin <kuprishuz@gmail.com>2010-01-31 14:42:40 -0500
committerJoshua Peek <josh@joshpeek.com>2010-01-31 13:46:27 -0600
commita3349f845ffa2415e12ac9e26b4f7300d7edd3ef (patch)
tree74f935f2c8dd814c15b54d2f6165212ea553f261 /actionpack
parent59e9478f57216999c12580c42cb9149894090123 (diff)
downloadrails-a3349f845ffa2415e12ac9e26b4f7300d7edd3ef.tar.gz
rails-a3349f845ffa2415e12ac9e26b4f7300d7edd3ef.tar.bz2
rails-a3349f845ffa2415e12ac9e26b4f7300d7edd3ef.zip
form_for should pass :remote to form_tag through html_options
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb2
-rw-r--r--actionpack/test/template/form_helper_test.rb19
2 files changed, 21 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index 20e9916d62..54610fdc71 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -280,6 +280,8 @@ module ActionView
args.unshift object
end
+ options[:html][:remote] = true if options.delete(:remote)
+
concat(form_tag(options.delete(:url) || {}, options.delete(:html) || {}))
fields_for(object_name, *(args << options), &proc)
concat('</form>'.html_safe!)
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb
index c97343fbe5..caeca9db10 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionpack/test/template/form_helper_test.rb
@@ -451,6 +451,25 @@ class FormHelperTest < ActionView::TestCase
assert_dom_equal expected, output_buffer
end
+ def test_form_for_with_remote
+ form_for(:post, @post, :remote => true, :html => { :id => 'create-post', :method => :put }) do |f|
+ concat f.text_field(:title)
+ concat f.text_area(:body)
+ concat f.check_box(:secret)
+ end
+
+ expected =
+ "<form action='http://www.example.com' id='create-post' method='post' data-remote='true'>" +
+ "<div style='margin:0;padding:0;display:inline'><input name='_method' type='hidden' value='put' /></div>" +
+ "<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' />" +
+ "</form>"
+
+ assert_dom_equal expected, output_buffer
+ end
+
def test_form_for_without_object
form_for(:post, :html => { :id => 'create-post' }) do |f|
concat f.text_field(:title)