public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Add options to field_set_tag

Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#1116 state:committed]
Andrew Kaspick (author)
Thu Sep 25 19:44:34 -0700 2008
NZKoz (committer)
Mon Sep 29 08:47:29 -0700 2008
commit  8c105ee0c888a63cdbf593f0bfe688065b3e09e2
tree    77cd68de0493f04fc746f1737c7b10bd79a26c3f
parent  28bf2fa03886e3ea7d873375239395b91b8e530e
...
403
404
405
 
406
407
408
...
414
415
416
417
 
 
 
 
 
 
418
419
 
420
421
422
...
403
404
405
406
407
408
409
...
415
416
417
 
418
419
420
421
422
423
424
 
425
426
427
428
0
@@ -403,6 +403,7 @@ module ActionView
0
       # Creates a field set for grouping HTML form elements.
0
       #
0
       # <tt>legend</tt> will become the fieldset's title (optional as per W3C).
0
+      # <tt>options</tt> accept the same values as tag.
0
       #
0
       # === Examples
0
       #   <% field_set_tag do %>
0
@@ -414,9 +415,14 @@ module ActionView
0
       #     <p><%= text_field_tag 'name' %></p>
0
       #   <% end %>
0
       #   # => <fieldset><legend>Your details</legend><p><input id="name" name="name" type="text" /></p></fieldset>
0
-      def field_set_tag(legend = nil, &block)
0
+      #
0
+      #   <% field_set_tag nil, :class => 'format' do %>
0
+      #     <p><%= text_field_tag 'name' %></p>
0
+      #   <% end %>
0
+      #   # => <fieldset class="format"><p><input id="name" name="name" type="text" /></p></fieldset>
0
+      def field_set_tag(legend = nil, options = nil, &block)
0
         content = capture(&block)
0
-        concat(tag(:fieldset, {}, true))
0
+        concat(tag(:fieldset, options, true))
0
         concat(content_tag(:legend, legend)) unless legend.blank?
0
         concat(content)
0
         concat("</fieldset>")
...
271
272
273
 
 
 
 
 
 
274
275
276
...
271
272
273
274
275
276
277
278
279
280
281
282
0
@@ -271,6 +271,12 @@ class FormTagHelperTest < ActionView::TestCase
0
 
0
     expected = %(<fieldset>Hello world!</fieldset>)
0
     assert_dom_equal expected, output_buffer
0
+
0
+    self.output_buffer = ''
0
+    field_set_tag('', :class => 'format') { concat "Hello world!" }
0
+
0
+    expected = %(<fieldset class="format">Hello world!</fieldset>)
0
+    assert_dom_equal expected, output_buffer
0
   end
0
 
0
   def protect_against_forgery?

Comments