Skip to content

Commit 90daef6

Browse files
authored
Merge pull request rails#50241 from seanpdoyle/fieldset-tag-alias
Alias `field_set_tag` helper to `fieldset_tag`
2 parents 9ec451f + c5ae44d commit 90daef6

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

actionview/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Alias `field_set_tag` helper to `fieldset_tag` to match `<fieldset>` element
2+
3+
*Sean Doyle*
4+
15
* Deprecate passing content to void elements when using `tag.br` type tag builders.
26

37
*Hartley McGuire*

actionview/lib/action_view/helpers/form_tag_helper.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -675,11 +675,13 @@ def image_submit_tag(source, options = {})
675675
# <% end %>
676676
# # => <fieldset class="format"><p><input id="name" name="name" type="text" /></p></fieldset>
677677
def field_set_tag(legend = nil, options = nil, &block)
678-
output = tag(:fieldset, options, true)
679-
output.safe_concat(content_tag("legend", legend)) unless legend.blank?
680-
output.concat(capture(&block)) if block_given?
681-
output.safe_concat("</fieldset>")
678+
content = []
679+
content << content_tag("legend", legend) unless legend.blank?
680+
content << capture(&block) if block_given?
681+
682+
content_tag(:fieldset, safe_join(content), options)
682683
end
684+
alias_method :fieldset_tag, :field_set_tag
683685

684686
# Creates a text field of type "color".
685687
#

actionview/test/template/form_tag_helper_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,11 @@ def test_field_set_tag_in_erb
925925
expected = %(<fieldset class="format">Hello world!</fieldset>)
926926
assert_dom_equal expected, output_buffer
927927

928+
output_buffer = render_erb("<%= fieldset_tag('', :class => 'format') do %>Hello world!<% end %>")
929+
930+
expected = %(<fieldset class="format">Hello world!</fieldset>)
931+
assert_dom_equal expected, output_buffer
932+
928933
output_buffer = render_erb("<%= field_set_tag %>")
929934

930935
expected = %(<fieldset></fieldset>)

0 commit comments

Comments
 (0)