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 %>
|
# <% end %>
|
||||||
# # => <fieldset class="format"><p><input id="name" name="name" type="text" /></p></fieldset>
|
# # => <fieldset class="format"><p><input id="name" name="name" type="text" /></p></fieldset>
|
||||||
def field_set_tag(legend = nil, options = nil, &block)
|
def field_set_tag(legend = nil, options = nil, &block)
|
||||||
content = capture(&block)
|
|
||||||
output = tag(:fieldset, options, true)
|
output = tag(:fieldset, options, true)
|
||||||
output.safe_concat(content_tag(:legend, legend)) unless legend.blank?
|
output.safe_concat(content_tag(:legend, legend)) unless legend.blank?
|
||||||
output.concat(content)
|
output.concat(capture(&block)) if block_given?
|
||||||
output.safe_concat("</fieldset>")
|
output.safe_concat("</fieldset>")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -513,6 +513,16 @@ class FormTagHelperTest < ActionView::TestCase
|
||||||
|
|
||||||
expected = %(<fieldset class="format">Hello world!</fieldset>)
|
expected = %(<fieldset class="format">Hello world!</fieldset>)
|
||||||
assert_dom_equal expected, output_buffer
|
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
|
end
|
||||||
|
|
||||||
def test_text_area_tag_options_symbolize_keys_side_effects
|
def test_text_area_tag_options_symbolize_keys_side_effects
|
||||||
|
|
Loading…
Reference in a new issue