From 6b5238aadeb778a7067f93376a6a57a8eeda8379 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 29 Jan 2007 20:42:46 +0000 Subject: [PATCH] Added FormBuilder#submit as a delegate for FormTagHelper#submit_tag [DHH] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6089 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/CHANGELOG | 2 ++ actionpack/lib/action_view/helpers/form_helper.rb | 4 ++++ actionpack/test/template/form_helper_test.rb | 2 ++ 3 files changed, 8 insertions(+) diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index a4385088a9..7c04549f50 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added FormBuilder#submit as a delegate for FormTagHelper#submit_tag [DHH] + * TestSession supports indifferent access so session['foo'] == session[:foo] in your tests. #7372 [julik, jean.helou] * Allow Routes to generate all urls for a set of options by specifying :generate_all => true. Allows caching to properly set or expire all paths for a resource. References #1739. [Nicholas Seckar] diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 84d1d8b670..71838c9d0b 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -453,6 +453,10 @@ module ActionView def error_messages(options = {}) @template.error_messages_for(@object_name, options) end + + def submit(value = "Save changes", options = {}) + @template.submit_tag(value, options.reverse_merge(:id => "#{object_name}_submit")) + end end end diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index df9295e8b7..88dc8aa1cd 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -239,6 +239,7 @@ class FormHelperTest < Test::Unit::TestCase _erbout.concat f.text_field(:title) _erbout.concat f.text_area(:body) _erbout.concat f.check_box(:secret) + _erbout.concat f.submit 'Create post' end expected = @@ -247,6 +248,7 @@ class FormHelperTest < Test::Unit::TestCase "" + "" + "" + + "" + "" assert_dom_equal expected, _erbout