From 0e6c8e5f6c168b9d376122f730c604d3758f4b04 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Thu, 6 Sep 2007 05:53:29 +0000 Subject: Add fieldset_tag for generating fieldsets, closes #9477. [djanowski] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7413 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../lib/action_view/helpers/form_tag_helper.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'actionpack/lib/action_view/helpers/form_tag_helper.rb') diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index c3cabb10f7..39e508f433 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -363,6 +363,28 @@ module ActionView def image_submit_tag(source, options = {}) tag :input, { "type" => "image", "src" => image_path(source) }.update(options.stringify_keys) end + + # Creates a field set for grouping HTML form elements. + # + # legend will become the fieldset's title (optional as per W3C). + # + # === Examples + # <% fieldset_tag do %> + #

<%= text_field_tag 'name' %>

+ # <% end %> + # # =>

+ # + # <% fieldset_tag 'Your details' do %> + #

<%= text_field_tag 'name' %>

+ # <% end %> + # # =>
Your details

+ def fieldset_tag(legend = nil, &block) + content = capture(&block) + concat(tag(:fieldset, {}, true), block.binding) + concat(content_tag(:legend, legend), block.binding) unless legend.blank? + concat(content, block.binding) + concat("", block.binding) + end private def html_options_for_form(url_for_options, options, *parameters_for_url) -- cgit v1.2.3