Permalink
Browse files

Add options to field_set_tag

Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#1116 state:committed]
  • Loading branch information...
1 parent 28bf2fa commit 8c105ee0c888a63cdbf593f0bfe688065b3e09e2 @akaspick akaspick committed with NZKoz Sep 26, 2008
@@ -403,6 +403,7 @@ def image_submit_tag(source, options = {})
# Creates a field set for grouping HTML form elements.
#
# <tt>legend</tt> will become the fieldset's title (optional as per W3C).
+ # <tt>options</tt> accept the same values as tag.
#
# === Examples
# <% field_set_tag do %>
@@ -414,9 +415,14 @@ def image_submit_tag(source, options = {})
# <p><%= text_field_tag 'name' %></p>
# <% end %>
# # => <fieldset><legend>Your details</legend><p><input id="name" name="name" type="text" /></p></fieldset>
- def field_set_tag(legend = nil, &block)
+ #
+ # <% field_set_tag nil, :class => 'format' do %>
+ # <p><%= text_field_tag 'name' %></p>
+ # <% end %>
+ # # => <fieldset class="format"><p><input id="name" name="name" type="text" /></p></fieldset>
+ 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("</fieldset>")
@@ -271,6 +271,12 @@ def test_field_set_tag_in_erb
expected = %(<fieldset>Hello world!</fieldset>)
assert_dom_equal expected, output_buffer
+
+ self.output_buffer = ''
+ field_set_tag('', :class => 'format') { concat "Hello world!" }
+
+ expected = %(<fieldset class="format">Hello world!</fieldset>)
+ assert_dom_equal expected, output_buffer
end
def protect_against_forgery?

0 comments on commit 8c105ee

Please sign in to comment.