From fc092a9cba5fceec38358072e50e09250cf58840 Mon Sep 17 00:00:00 2001 From: Carlos Galdino Date: Fri, 1 Jun 2012 19:10:18 -0300 Subject: Deprecate `:confirm` in favor of `:data => { :confirm => 'Text' }` option This deprecation applies to: `button_to` `button_tag` `image_submit_tag` `link_to` `submit_tag` As :confirm is an UI specific option is better to use the data attributes, teaching users about unobtrusive JavaScript and how Rails works with it. --- actionpack/lib/action_view/helpers/form_tag_helper.rb | 6 ++++++ actionpack/lib/action_view/helpers/url_helper.rb | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_view/helpers') diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index 3d3ae44eb4..ef278939d1 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -423,6 +423,8 @@ module ActionView end if confirm = options.delete("confirm") + ActiveSupport::Deprecation.warn ":confirm option is deprecated and will be removed from Rails 4.0. Use ':data => { :confirm => \'Text\' }' instead" + options["data-confirm"] = confirm end @@ -475,6 +477,8 @@ module ActionView end if confirm = options.delete("confirm") + ActiveSupport::Deprecation.warn ":confirm option is deprecated and will be removed from Rails 4.0. Use ':data => { :confirm => \'Text\' }' instead" + options["data-confirm"] = confirm end @@ -510,6 +514,8 @@ module ActionView options = options.stringify_keys if confirm = options.delete("confirm") + ActiveSupport::Deprecation.warn ":confirm option is deprecated and will be removed from Rails 4.0. Use ':data => { :confirm => \'Text\' }' instead" + options["data-confirm"] = confirm end diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index 6f05881d08..d044afa6e6 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -628,8 +628,13 @@ module ActionView html_options["data-disable-with"] = disable_with end - html_options["data-confirm"] = confirm if confirm - add_method_to_attributes!(html_options, method) if method + if confirm + ActiveSupport::Deprecation.warn ":confirm option is deprecated and will be removed from Rails 4.0. Use ':data => { :confirm => \'Text\' }' instead" + + html_options["data-confirm"] = confirm + end + + add_method_to_attributes!(html_options, method) if method html_options else -- cgit v1.2.3