aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/form_tag_helper.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-10-23 23:30:36 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-10-23 23:30:36 +0000
commite407b44ba14e5ab72f25ca107291e7a4d51051b8 (patch)
tree0c4a6ff856a4d42d8e0f8c779cd01659946fca38 /actionpack/lib/action_view/helpers/form_tag_helper.rb
parent6c062054cdb236fead5d09679985ebb70d8b053a (diff)
downloadrails-e407b44ba14e5ab72f25ca107291e7a4d51051b8.tar.gz
rails-e407b44ba14e5ab72f25ca107291e7a4d51051b8.tar.bz2
rails-e407b44ba14e5ab72f25ca107291e7a4d51051b8.zip
Made FormTagHelper#form_tag work with blocks, rendering start/end_form_tag deprecated
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5345 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers/form_tag_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/form_tag_helper.rb11
1 files changed, 9 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 5bfa1eefca..8d6d8e99ea 100644
--- a/actionpack/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -17,7 +17,7 @@ module ActionView
# * <tt>:method</tt> - The method to use when submitting the form, usually either "get" or "post".
# If "put", "delete", or another verb is used, a hidden input with name _method
# is added to simulate the verb over post.
- def form_tag(url_for_options = {}, options = {}, *parameters_for_url, &proc)
+ def form_tag(url_for_options = {}, options = {}, *parameters_for_url, &block)
html_options = options.stringify_keys
html_options["enctype"] = "multipart/form-data" if html_options.delete("multipart")
html_options["action"] = url_for(url_for_options, *parameters_for_url)
@@ -34,7 +34,14 @@ module ActionView
method_tag = tag(:input, :type => "hidden", :name => "_method", :value => method)
end
- tag(:form, html_options, true) + method_tag
+ if block_given?
+ content = capture(&block)
+ concat(tag(:form, html_options, true) + method_tag, block.binding)
+ concat(content, block.binding)
+ concat("</form>", block.binding)
+ else
+ tag(:form, html_options, true) + method_tag
+ end
end
alias_method :start_form_tag, :form_tag