aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/tags
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-01-16 23:15:07 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-01-17 00:05:30 -0300
commit7d2846b9dbb728d304347a8e70dbe845d4efbb35 (patch)
tree48c90fad69c4d92a37f963a534c5a35fa24e8302 /actionpack/lib/action_view/helpers/tags
parent9eb6cd6373cf8c1142e1f3cd9e3af55d47828bd7 (diff)
downloadrails-7d2846b9dbb728d304347a8e70dbe845d4efbb35.tar.gz
rails-7d2846b9dbb728d304347a8e70dbe845d4efbb35.tar.bz2
rails-7d2846b9dbb728d304347a8e70dbe845d4efbb35.zip
Extract GroupedCollectionSelect
Diffstat (limited to 'actionpack/lib/action_view/helpers/tags')
-rw-r--r--actionpack/lib/action_view/helpers/tags/grouped_collection_select.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/tags/grouped_collection_select.rb b/actionpack/lib/action_view/helpers/tags/grouped_collection_select.rb
new file mode 100644
index 0000000000..507466a57a
--- /dev/null
+++ b/actionpack/lib/action_view/helpers/tags/grouped_collection_select.rb
@@ -0,0 +1,24 @@
+module ActionView
+ module Helpers
+ module Tags
+ class GroupedCollectionSelect < Base #:nodoc:
+ def initialize(object_name, method_name, template_object, collection, group_method, group_label_method, option_key_method, option_value_method, options, html_options)
+ @collection = collection
+ @group_method = group_method
+ @group_label_method = group_label_method
+ @option_key_method = option_key_method
+ @option_value_method = option_value_method
+ @html_options = html_options
+
+ super(object_name, method_name, template_object, options)
+ end
+
+ def render
+ select_content_tag(
+ option_groups_from_collection_for_select(@collection, @group_method, @group_label_method, @option_key_method, @option_value_method, value(@object)), @options, @html_options
+ )
+ end
+ end
+ end
+ end
+end