diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md index d12513b52c74f..2d30d9dd69a7e 100644 --- a/actionview/CHANGELOG.md +++ b/actionview/CHANGELOG.md @@ -1,3 +1,7 @@ +* Alias `field_set_tag` helper to `fieldset_tag` to match `
` element + + *Sean Doyle* + * Deprecate passing content to void elements when using `tag.br` type tag builders. *Hartley McGuire* diff --git a/actionview/lib/action_view/helpers/form_tag_helper.rb b/actionview/lib/action_view/helpers/form_tag_helper.rb index d5acfb2adfa9e..a7c864e467664 100644 --- a/actionview/lib/action_view/helpers/form_tag_helper.rb +++ b/actionview/lib/action_view/helpers/form_tag_helper.rb @@ -675,11 +675,13 @@ def image_submit_tag(source, options = {}) # <% end %> # # =>

def field_set_tag(legend = nil, options = nil, &block) - output = tag(:fieldset, options, true) - output.safe_concat(content_tag("legend", legend)) unless legend.blank? - output.concat(capture(&block)) if block_given? - output.safe_concat("
") + content = [] + content << content_tag("legend", legend) unless legend.blank? + content << capture(&block) if block_given? + + content_tag(:fieldset, safe_join(content), options) end + alias_method :fieldset_tag, :field_set_tag # Creates a text field of type "color". # diff --git a/actionview/test/template/form_tag_helper_test.rb b/actionview/test/template/form_tag_helper_test.rb index 62745dbc70c99..34a5ce3a91542 100644 --- a/actionview/test/template/form_tag_helper_test.rb +++ b/actionview/test/template/form_tag_helper_test.rb @@ -925,6 +925,11 @@ def test_field_set_tag_in_erb expected = %(
Hello world!
) assert_dom_equal expected, output_buffer + output_buffer = render_erb("<%= fieldset_tag('', :class => 'format') do %>Hello world!<% end %>") + + expected = %(
Hello world!
) + assert_dom_equal expected, output_buffer + output_buffer = render_erb("<%= field_set_tag %>") expected = %(
)