Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactor option groups to use content_tag

[Carlos Antonio da Silva + Rafael Mendonça França]
  • Loading branch information...
commit 595271cbd2a763103223026b893a4ca3c98978c7 1 parent d9fc3dc
@carlosantoniodasilva carlosantoniodasilva authored
Showing with 4 additions and 4 deletions.
  1. +4 −4 actionpack/lib/action_view/helpers/form_options_helper.rb
View
8 actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -418,10 +418,10 @@ def options_from_collection_for_select(collection, value_method, text_method, se
# wrap the output in an appropriate <tt><select></tt> tag.
def option_groups_from_collection_for_select(collection, group_method, group_label_method, option_key_method, option_value_method, selected_key = nil)
collection.map do |group|
- group_label_string = group.send(group_label_method)
- "<optgroup label=\"#{ERB::Util.html_escape(group_label_string)}\">" +
- options_from_collection_for_select(group.send(group_method), option_key_method, option_value_method, selected_key) +
- '</optgroup>'
+ option_tags = options_from_collection_for_select(
+ group.send(group_method), option_key_method, option_value_method, selected_key)
+
+ content_tag(:optgroup, option_tags, :label => group.send(group_label_method))
end.join.html_safe
end
Please sign in to comment.
Something went wrong with that request. Please try again.