From 0e207a499f82c7aefabcddad04fc562df727e663 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Sat, 19 May 2012 09:49:01 -0300 Subject: Clarify grouped_options_for_select method API, add changelog entry Make the method API more clear by explicitly showing the expected arguments. This means that the options cannot be passed as second argument because we are not relying on extract_options! anymore, you are expected to give a selected key or `nil` if you want to pass options, as it is the last argument. Notice that this does not change the current method arguments contract available in 3.2, it just brings back the same functionality with the divider addition. --- actionpack/CHANGELOG.md | 4 ++++ .../lib/action_view/helpers/form_options_helper.rb | 27 +++++++++++----------- .../test/template/form_options_helper_test.rb | 4 ++-- 3 files changed, 19 insertions(+), 16 deletions(-) (limited to 'actionpack') diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index 41af29573e..e625bbe7af 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,5 +1,9 @@ ## Rails 4.0.0 (unreleased) ## +* Add `divider` option to `grouped_options_for_select` to generate a separator + `optgroup` automatically, and deprecate `prompt` as third argument, in favor + of using an options hash. *Nicholas Greenfield* + * Add `time_field` and `time_field_tag` helpers which render an `input[type="time"]` tag. *Alex Soulim* * Removed old text_helper apis for highlight, excerpt and word_wrap *Jeremy Walker* diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb index 52eb1aa447..eef426703d 100644 --- a/actionpack/lib/action_view/helpers/form_options_helper.rb +++ b/actionpack/lib/action_view/helpers/form_options_helper.rb @@ -477,8 +477,8 @@ module ActionView # # Sample usage (Hash): # grouped_options = { - # 'North America' => [['United States','US'], 'Canada'], - # 'Europe' => ['Denmark','Germany','France'] + # 'North America' => [['United States','US'], 'Canada'], + # 'Europe' => ['Denmark','Germany','France'] # } # grouped_options_for_select(grouped_options) # @@ -495,10 +495,10 @@ module ActionView # # Sample usage (divider): # grouped_options = [ - # [['United States','US'], 'Canada'], - # ['Denmark','Germany','France'] + # [['United States','US'], 'Canada'], + # ['Denmark','Germany','France'] # ] - # grouped_options_for_select(grouped_options, divider: '---------') + # grouped_options_for_select(grouped_options, nil, divider: '---------') # # Possible output: # @@ -513,15 +513,14 @@ module ActionView # # Note: Only the and tags are returned, so you still have to # wrap the output in an appropriate