diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 00e12bd1e9a63324fea917b8133ae9310e94aa8e..ef1c51d4e7afc38fe7f3dfaf2475dc09479f3feb 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -1072,16 +1072,21 @@ def error_messages(options = {}) @template.error_messages_for(@object_name, objectify_options(options)) end - def submit(value = nil, options = {}) - value ||= begin - key = @object ? (@object.new_record? ? :create : :update) : :submit - model = if @object.class.respond_to?(:model_name) - @object.class.model_name.human + def submit(value=nil, options={}) + value, options = nil, value if value.is_a?(Hash) + + unless value + object = @object.respond_to?(:to_model) ? @object.to_model : @object + key = object ? (object.new_record? ? :create : :update) : :submit + + model = if object.class.respond_to?(:model_name) + object.class.model_name.human else @object_name.to_s.humanize end - I18n.t(:"helpers.submit.#{key}", :model => model, :default => "#{key.to_s.humanize} #{model}") + value = I18n.t(:"helpers.submit.#{key}", :model => model, + :default => "#{key.to_s.humanize} #{model}") end @template.submit_tag(value, options.reverse_merge(:id => "#{object_name}_submit")) diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index c62bc6f4a826817f930381aff73a7e58d5813eb0..2f6d97de3d8d7ff70f9e783f83043e0324d22743 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -521,11 +521,11 @@ def test_submit_without_object_and_locale_strings old_locale, I18n.locale = I18n.locale, :submit form_for(:post) do |f| - concat f.submit + concat f.submit :class => "extra" end expected = "
" + - "" + + "" + "
" assert_dom_equal expected, output_buffer ensure