From 1f94d80babc0b934b233b8f1cf3f5653bf51e75f Mon Sep 17 00:00:00 2001 From: codeape Date: Sun, 9 Aug 2009 19:18:01 -0700 Subject: [PATCH] Created grouped_collection_select --- .../lib/action_view/helpers/form_options_helper.rb | 54 ++++++++++++++++++++ .../test/template/form_options_helper_test.rb | 34 ++++++++++++ 2 files changed, 88 insertions(+), 0 deletions(-) diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb index 8cb5882..2cb7199 100644 --- a/actionpack/lib/action_view/helpers/form_options_helper.rb +++ b/actionpack/lib/action_view/helpers/form_options_helper.rb @@ -162,6 +162,47 @@ module ActionView InstanceTag.new(object, method, self, options.delete(:object)).to_collection_select_tag(collection, value_method, text_method, options, html_options) end + + # Returns \n\n", + grouped_collection_select("post", "origin", @continents, :countries, :continent_name, :country_id, :country_name) + ) + end + + def test_grouped_collection_select_under_fields_for + @continents = [ + Continent.new("", [Country.new("", ""), Country.new("so", "Somalia")] ), + Continent.new("Europe", [Country.new("dk", "Denmark"), Country.new("ie", "Ireland")] ) + ] + + @post = Post.new + @post.origin = 'dk' + + fields_for :post, @post do |f| + concat f.grouped_collection_select("origin", @continents, :countries, :continent_name, :country_id, :country_name) + end + + assert_dom_equal( + "", + output_buffer + ) + end + private def dummy_posts -- 1.6.1.2