mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Allow fieldsets to be created without a block.
This commit is contained in:
parent
447d87c206
commit
81d3493c17
2 changed files with 11 additions and 2 deletions
|
@ -525,10 +525,9 @@ module ActionView
|
|||
# <% 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
|
||||
|
||||
|
|
|
@ -513,6 +513,16 @@ class FormTagHelperTest < ActionView::TestCase
|
|||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue