Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow fieldsets to be created without a block.

  • Loading branch information...
commit 81d3493c172dc717a86e81a855f4983a3774b846 1 parent 447d87c
@benpickles authored
View
3  actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -525,10 +525,9 @@ def image_submit_tag(source, options = {})
# <% 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)
output = tag(:fieldset, options, true)
output.safe_concat(content_tag(:legend, legend)) unless legend.blank?
- output.concat(content)
+ output.concat(capture(&block)) if block_given?
output.safe_concat("</fieldset>")
end
View
10 actionpack/test/template/form_tag_helper_test.rb
@@ -513,6 +513,16 @@ def test_field_set_tag_in_erb
expected = %(<fieldset class="format">Hello world!</fieldset>)
assert_dom_equal expected, output_buffer
+
+ output_buffer = render_erb("<%= field_set_tag %>")
+
+ expected = %(<fieldset></fieldset>)
+ assert_dom_equal expected, output_buffer
+
+ output_buffer = render_erb("<%= field_set_tag('You legend!') %>")
+
+ expected = %(<fieldset><legend>You legend!</legend></fieldset>)
+ assert_dom_equal expected, output_buffer
end
def test_text_area_tag_options_symbolize_keys_side_effects
Please sign in to comment.
Something went wrong with that request. Please try again.