Skip to content
This repository
Browse code

Mark the result of grouped_options_for_select as HTML safe [#4322 sta…

…te:committed]

Signed-off-by: Xavier Noria <fxn@hashref.com>
  • Loading branch information...
commit 001ca893c6f061796a2c3f03c864fdf06c9efbb1 1 parent 66b55db
Kieran Pilkington authored fxn committed
2  actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -444,7 +444,7 @@ def grouped_options_for_select(grouped_options, selected_key = nil, prompt = nil
444 444 body << content_tag(:optgroup, options_for_select(group[1], selected_key), :label => group[0])
445 445 end
446 446
447   - body
  447 + body.html_safe
448 448 end
449 449
450 450 # Returns a string of option tags for pretty much any time zone in the
4 actionpack/test/template/form_options_helper_test.rb
@@ -207,6 +207,10 @@ def test_grouped_options_for_select_with_selected_and_prompt
207 207 )
208 208 end
209 209
  210 + def test_grouped_options_for_select_returns_html_safe_string
  211 + assert grouped_options_for_select([["Hats", ["Baseball Cap","Cowboy Hat"]]]).html_safe?
  212 + end
  213 +
210 214 def test_optgroups_with_with_options_with_hash
211 215 assert_dom_equal(
212 216 "<optgroup label=\"Europe\"><option value=\"Denmark\">Denmark</option>\n<option value=\"Germany\">Germany</option></optgroup><optgroup label=\"North America\"><option value=\"United States\">United States</option>\n<option value=\"Canada\">Canada</option></optgroup>",

0 comments on commit 001ca89

Please sign in to comment.
Something went wrong with that request. Please try again.