diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index 140fcfc0ca..6515a7b392 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,5 +1,10 @@ ## Rails 4.0.0 (unreleased) ## +* `image_submit_tag` will set `alt` attribute from image source if not + specified. + + *Nihad Abbasov* + * Do not generate local variables for partials without object or collection. Previously rendering a partial without giving `:object` or `:collection` would generate a local variable with the partial name by default. diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index 479739bebd..5745286464 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -526,19 +526,19 @@ module ActionView # # ==== Examples # image_submit_tag("login.png") - # # => + # # => # # image_submit_tag("purchase.png", disabled: true) - # # => + # # => # - # image_submit_tag("search.png", class: 'search_button') - # # => + # image_submit_tag("search.png", class: 'search_button', alt: 'Find') + # # => # # image_submit_tag("agree.png", disabled: true, class: "agree_disagree_button") - # # => + # # => # # image_submit_tag("save.png", data: { confirm: "Are you sure?" }) - # # => + # # => def image_submit_tag(source, options = {}) options = options.stringify_keys @@ -550,7 +550,7 @@ module ActionView options["data-confirm"] = confirm end - tag :input, { "type" => "image", "src" => path_to_image(source) }.update(options) + tag :input, { "alt" => image_alt(source), "type" => "image", "src" => path_to_image(source) }.update(options) end # Creates a field set for grouping HTML form elements. diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index 0a94fa079b..6c6a142397 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -488,7 +488,7 @@ class FormTagHelperTest < ActionView::TestCase def test_image_submit_tag_with_confirmation assert_dom_equal( - %(), + %(), image_submit_tag("save.gif", :data => { :confirm => "Are you sure?" }) ) end @@ -496,7 +496,7 @@ class FormTagHelperTest < ActionView::TestCase def test_image_submit_tag_with_deprecated_confirmation assert_deprecated ":confirm option is deprecated and will be removed from Rails 4.1. Use 'data: { confirm: \'Text\' }' instead" do assert_dom_equal( - %(), + %(), image_submit_tag("save.gif", :confirm => "Are you sure?") ) end