aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/CHANGELOG4
-rw-r--r--actionpack/lib/action_view/helpers/form_tag_helper.rb7
-rw-r--r--actionpack/test/template/form_tag_helper_test.rb2
3 files changed, 10 insertions, 3 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index fd52b0535e..a470bb5fb7 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,6 +1,8 @@
*SVN*
-# Fix #render_file so that TemplateError is called with the correct params and you don't get the WSOD. [Rick]
+* Fix that FormTagHelper#submit_tag using :disable_with should trigger the onsubmit handler of its form if available [DHH]
+
+* Fix #render_file so that TemplateError is called with the correct params and you don't get the WSOD. [Rick]
* Fix issue with deprecation messing up #template_root= usage. Add #prepend_view_path and #append_view_path to allow modification of a copy of the
superclass' view_paths. [Rick]
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb
index 3b0e555bbd..7f77788d41 100644
--- a/actionpack/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -141,7 +141,12 @@ module ActionView
options.stringify_keys!
if disable_with = options.delete("disable_with")
- options["onclick"] = "this.disabled=true;this.value='#{disable_with}';this.form.submit();#{options["onclick"]}"
+ options["onclick"] = [
+ "this.disabled=true",
+ "this.value='#{disable_with}'",
+ "#{options["onclick"]}",
+ "return (this.form.onsubmit ? this.form.onsubmit() : true)",
+ ].join(";")
end
tag :input, { "type" => "submit", "name" => "commit", "value" => value }.update(options.stringify_keys)
diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb
index dc36d23604..e7fd3b0823 100644
--- a/actionpack/test/template/form_tag_helper_test.rb
+++ b/actionpack/test/template/form_tag_helper_test.rb
@@ -132,7 +132,7 @@ class FormTagHelperTest < Test::Unit::TestCase
def test_submit_tag
assert_dom_equal(
- %(<input name='commit' type='submit' value='Save' onclick="this.disabled=true;this.value='Saving...';this.form.submit();alert('hello!')" />),
+ %(<input name='commit' type='submit' value='Save' onclick="this.disabled=true;this.value='Saving...';alert('hello!');return (this.form.onsubmit ? this.form.onsubmit() : true)" />),
submit_tag("Save", :disable_with => "Saving...", :onclick => "alert('hello!')")
)
end