diff options
author | Carlos Galdino + Rafael Mendonça França <rafael.franca+carlos.galdino@plataformatec.com.br> | 2012-07-21 15:20:26 -0300 |
---|---|---|
committer | Carlos Galdino + Rafael Mendonça França <rafael.franca+carlos.galdino@plataformatec.com.br> | 2012-07-21 15:20:26 -0300 |
commit | 9345a116af134e6963cda261c448c9ecdb3832ea (patch) | |
tree | 9ddb84ffdf09c799690cf10ec9614bed05c53148 /actionpack/lib/action_view/helpers/form_tag_helper.rb | |
parent | f5d0e3d7605cc05b0fd549d2b89c9d1db48ce093 (diff) | |
download | rails-9345a116af134e6963cda261c448c9ecdb3832ea.tar.gz rails-9345a116af134e6963cda261c448c9ecdb3832ea.tar.bz2 rails-9345a116af134e6963cda261c448c9ecdb3832ea.zip |
Add back `:confirm` and change deprecation horizon to 4.1
Diffstat (limited to 'actionpack/lib/action_view/helpers/form_tag_helper.rb')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_tag_helper.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index 4b8484bfb5..87f1f4d92f 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -386,6 +386,12 @@ module ActionView # * <tt>:disabled</tt> - If true, the user will not be able to use this input. # * Any other key creates standard HTML options for the tag. # + # ==== Data attributes + # + # * <tt>:confirm => 'question?'</tt> - If present the unobtrusive JavaScript + # drivers will provide a prompt with the question specified. If the user accepts, + # the form is processed normally, otherwise no action is taken. + # # ==== Examples # submit_tag # # => <input name="commit" type="submit" value="Save changes" /> @@ -411,6 +417,12 @@ module ActionView def submit_tag(value = "Save changes", options = {}) options = options.stringify_keys + if confirm = options.delete("confirm") + ActiveSupport::Deprecation.warn ":confirm option is deprecated and will be removed from Rails 4.1. Use ':data => { :confirm => \'Text\' }' instead'" + + options["data-confirm"] = confirm + end + tag :input, { "type" => "submit", "name" => "commit", "value" => value }.update(options) end @@ -427,6 +439,13 @@ module ActionView # use this input. # * Any other key creates standard HTML options for the tag. # + # ==== Data attributes + # + # * <tt>:confirm => 'question?'</tt> - If present, the + # unobtrusive JavaScript drivers will provide a prompt with + # the question specified. If the user accepts, the form is + # processed normally, otherwise no action is taken. + # # ==== Examples # button_tag # # => <button name="button" type="submit">Button</button> @@ -443,6 +462,12 @@ module ActionView options ||= {} options = options.stringify_keys + if confirm = options.delete("confirm") + ActiveSupport::Deprecation.warn ":confirm option is deprecated and will be removed from Rails 4.1. Use ':data => { :confirm => \'Text\' }' instead'" + + options["data-confirm"] = confirm + end + options.reverse_merge! 'name' => 'button', 'type' => 'submit' content_tag :button, content_or_options || 'Button', options, &block @@ -457,6 +482,12 @@ module ActionView # * <tt>:disabled</tt> - If set to true, the user will not be able to use this input. # * Any other key creates standard HTML options for the tag. # + # ==== Data attributes + # + # * <tt>:confirm => 'question?'</tt> - This will add a JavaScript confirm + # prompt with the question specified. If the user accepts, the form is + # processed normally, otherwise no action is taken. + # # ==== Examples # image_submit_tag("login.png") # # => <input src="/images/login.png" type="image" /> @@ -475,6 +506,12 @@ module ActionView def image_submit_tag(source, options = {}) options = options.stringify_keys + if confirm = options.delete("confirm") + ActiveSupport::Deprecation.warn ":confirm option is deprecated and will be removed from Rails 4.1. Use ':data => { :confirm => \'Text\' }' instead'" + + options["data-confirm"] = confirm + end + tag :input, { "type" => "image", "src" => path_to_image(source) }.update(options) end |