diff options
author | Yuki Nishijima <mail@yukinishijima.net> | 2012-06-05 04:30:40 +0900 |
---|---|---|
committer | Yuki Nishijima <mail@yukinishijima.net> | 2012-06-05 04:30:40 +0900 |
commit | 0ec88cd1c83bdd66d06c2b475e0ace6c41be475e (patch) | |
tree | 033c13183540d14c41164ffb990e2936fc6dcacf /actionpack/lib/action_view/helpers | |
parent | 2186540f9160b47e075b9926d12d3a6843e95d31 (diff) | |
download | rails-0ec88cd1c83bdd66d06c2b475e0ace6c41be475e.tar.gz rails-0ec88cd1c83bdd66d06c2b475e0ace6c41be475e.tar.bz2 rails-0ec88cd1c83bdd66d06c2b475e0ace6c41be475e.zip |
accept a block in button helper.
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 15 |
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? |