diff options
author | Nicholas Seckar <nseckar@gmail.com> | 2006-02-06 05:06:36 +0000 |
---|---|---|
committer | Nicholas Seckar <nseckar@gmail.com> | 2006-02-06 05:06:36 +0000 |
commit | 7139e2a0e1c24788758ccd6131ba86243de84bf6 (patch) | |
tree | d849489ad5728d24e63debbae8f88d68f2e8e1cb /actionpack | |
parent | 796295dba6839bf417c19a2f41fe2a32d968367a (diff) | |
download | rails-7139e2a0e1c24788758ccd6131ba86243de84bf6.tar.gz rails-7139e2a0e1c24788758ccd6131ba86243de84bf6.tar.bz2 rails-7139e2a0e1c24788758ccd6131ba86243de84bf6.zip |
Fix remote_form_for creates a non-ajax form. Closes #3741.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3545 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 10 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/prototype_helper.rb | 2 | ||||
-rw-r--r-- | actionpack/test/template/form_helper_test.rb | 2 |
4 files changed, 11 insertions, 5 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index a84487789a..d720370f24 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fix remote_form_for creates a non-ajax form. [Rick Olson] + * Don't let arbitrary classes match as controllers -- a potentially dangerous bug. [Nicholas Seckar] * Fix Routing tests. Fix routing where failing to match a controller would prevent the rest of routes from being attempted. [Nicholas Seckar] diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 75c09dfe87..9473b59563 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -117,13 +117,17 @@ module ActionView def form_for(object_name, object, options = {}, &proc) raise ArgumentError, "form_for requires a block!" unless proc - url_options = options.delete :url + url_options = options.delete(:url) || {} form_tag_selector = options.delete(:form_tag_selector) || :form_tag - form_options = {} + form_options = {} [:method, :multipart].each { |key| form_options[key] = options.delete(key) if options.key? key } fields_for(object_name, object, options.merge(:proc => proc)) do |builder| - concat send(form_tag_selector, url_options, form_options), proc.binding + if form_tag_selector == :form_remote_tag + concat send(form_tag_selector, form_options.merge(:url => url_options)), proc.binding + else + concat send(form_tag_selector, url_options, form_options), proc.binding + end builder.build_form(url_options, form_options) { proc.call builder } concat end_form_tag, proc.binding end diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb index 2cd7550c65..523adb3288 100644 --- a/actionpack/lib/action_view/helpers/prototype_helper.rb +++ b/actionpack/lib/action_view/helpers/prototype_helper.rb @@ -172,7 +172,7 @@ module ActionView # Works like form_remote_tag, but uses form_for semantics. def remote_form_for(object_name, object, options = {}, &proc) - form_for(object_name, object, options.merge(:form_for_select => :form_remote_tag), &proc) + form_for(object_name, object, options.merge(:form_tag_selector => :form_remote_tag), &proc) end alias_method :form_remote_for, :remote_form_for diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 6cc4b50d67..a922584370 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -304,7 +304,7 @@ class FormHelperTest < Test::Unit::TestCase end expected = - "<form action='http://www.example.com' method='post'>" + + %(<form action="http://www.example.com" onsubmit="new Ajax.Request('http://www.example.com', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;" method="post">) + "<label for='title'>Title:</label> <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /><br/>" + "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea><br/>" + "<label for='secret'>Secret:</label> <input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" + |