From 8c105ee0c888a63cdbf593f0bfe688065b3e09e2 Mon Sep 17 00:00:00 2001 From: Andrew Kaspick Date: Thu, 25 Sep 2008 21:44:34 -0500 Subject: Add options to field_set_tag Signed-off-by: Michael Koziarski [#1116 state:committed] --- actionpack/lib/action_view/helpers/form_tag_helper.rb | 10 ++++++++-- actionpack/test/template/form_tag_helper_test.rb | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index 294c22521e..208bf91dd4 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -403,6 +403,7 @@ module ActionView # Creates a field set for grouping HTML form elements. # # legend will become the fieldset's title (optional as per W3C). + # options accept the same values as tag. # # === Examples # <% field_set_tag do %> @@ -414,9 +415,14 @@ module ActionView #

<%= text_field_tag 'name' %>

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

- def field_set_tag(legend = nil, &block) + # + # <% field_set_tag nil, :class => 'format' do %> + #

<%= text_field_tag 'name' %>

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

+ def field_set_tag(legend = nil, options = nil, &block) content = capture(&block) - concat(tag(:fieldset, {}, true)) + concat(tag(:fieldset, options, true)) concat(content_tag(:legend, legend)) unless legend.blank? concat(content) concat("") diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index 6473d011d5..ad8baef5e4 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -271,6 +271,12 @@ class FormTagHelperTest < ActionView::TestCase expected = %(
Hello world!
) assert_dom_equal expected, output_buffer + + self.output_buffer = '' + field_set_tag('', :class => 'format') { concat "Hello world!" } + + expected = %(
Hello world!
) + assert_dom_equal expected, output_buffer end def protect_against_forgery? -- cgit v1.2.3