aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2012-06-05 01:20:43 -0700
committerJosé Valim <jose.valim@gmail.com>2012-06-05 01:20:43 -0700
commit76830e110a73d6db0dafd42fc960686637cbfc7b (patch)
tree0b99ab7793fb54836a3375033ae94f80788a42ff /actionpack/lib
parentfedb0e27a42172a89441d4dea8816eb8e794dad4 (diff)
parent0ec88cd1c83bdd66d06c2b475e0ace6c41be475e (diff)
downloadrails-76830e110a73d6db0dafd42fc960686637cbfc7b.tar.gz
rails-76830e110a73d6db0dafd42fc960686637cbfc7b.tar.bz2
rails-76830e110a73d6db0dafd42fc960686637cbfc7b.zip
Merge pull request #6631 from yuki24/use_block_in_button_helper
Accept a block in FormHelper#button
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index ac150882b1..7dd35f7357 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -1311,10 +1311,21 @@ module ActionView
# post:
# create: "Add %{model}"
#
- def button(value=nil, options={})
+ # ==== Examples
+ # button("Create a post")
+ # # => <button name='button' type='submit'>Create post</button>
+ #
+ # button do
+ # content_tag(:strong, 'Ask me!')
+ # end
+ # # => <button name='button' type='submit'>
+ # # <strong>Ask me!</strong>
+ # # </button>
+ #
+ def button(value = nil, options = {}, &block)
value, options = nil, value if value.is_a?(Hash)
value ||= submit_default_value
- @template.button_tag(value, options)
+ @template.button_tag(value, options, &block)
end
def emitted_hidden_id?