diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2008-03-24 21:24:40 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-03-24 21:24:40 +0000 |
commit | 123f5a357dc176225d57dc78e773338642048120 (patch) | |
tree | 9981644698a0d3bc8982b30984b7b00adf1b5364 /actionpack/lib/action_view/helpers | |
parent | 0e62c773f603f885743d52f44fb032290f809cae (diff) | |
download | rails-123f5a357dc176225d57dc78e773338642048120.tar.gz rails-123f5a357dc176225d57dc78e773338642048120.tar.bz2 rails-123f5a357dc176225d57dc78e773338642048120.zip |
Added :confirm option to submit_tag (closes #11415) [miloops]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9087 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_tag_helper.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index 23b908ddc6..0544ed3ded 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -316,6 +316,9 @@ module ActionView # Creates a submit button with the text <tt>value</tt> as the caption. # # ==== Options + # * <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. # * <tt>:disabled</tt> - If set to true, the user will not be able to use this input. # * <tt>:disable_with</tt> - Value of this parameter will be used as the value for a disabled version # of the submit button when the form is submitted. @@ -351,10 +354,15 @@ module ActionView "#{options["onclick"]}", "result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit())", "if (result == false) { this.value = this.getAttribute('originalValue'); this.disabled = false }", - "return result", + "return result;", ].join(";") end - + + if confirm = options.delete("confirm") + options["onclick"] ||= '' + options["onclick"] += "return #{confirm_javascript_function(confirm)};" + end + tag :input, { "type" => "submit", "name" => "commit", "value" => value }.update(options.stringify_keys) end |