aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-12-21 22:18:07 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-12-21 22:18:07 +0000
commita81333f115c877fc59601f4e0766df4bdce4a8d8 (patch)
treec2d1cfc1529a6c74e41680a427b0926fc9a78d52 /actionpack/lib
parent470fc0209699d70e9e2349d35f3210757a7a7d17 (diff)
downloadrails-a81333f115c877fc59601f4e0766df4bdce4a8d8.tar.gz
rails-a81333f115c877fc59601f4e0766df4bdce4a8d8.tar.bz2
rails-a81333f115c877fc59601f4e0766df4bdce4a8d8.zip
Add :default option to time_zone_select. Closes #10590.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8473 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_view/helpers/form_options_helper.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb
index 0f1d2b02bf..67be4d81f0 100644
--- a/actionpack/lib/action_view/helpers/form_options_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -131,6 +131,17 @@ module ActionView
# to TimeZone. This may be used by users to specify a different time
# zone model object. (See #time_zone_options_for_select for more
# information.)
+ # Finally, this method supports a <tt>:default</tt> option, which selects
+ # a default TimeZone if the object's time zone is nil.
+ #
+ # Examples:
+ # time_zone_select( "user", "time_zone", nil, :include_blank => true)
+ #
+ # time_zone_select( "user", "time_zone", nil, :default => "Pacific Time (US & Canada)" )
+ #
+ # time_zone_select( "user", 'time_zone', TimeZone.us_zones, :default => "Pacific Time (US & Canada)")
+ #
+ # time_zone_select( "user", "time_zone", TZInfo::Timezone.all.sort, :model => TZInfo::Timezone)
def time_zone_select(object, method, priority_zones = nil, options = {}, html_options = {})
InstanceTag.new(object, method, self, nil, options.delete(:object)).to_time_zone_select_tag(priority_zones, options, html_options)
end
@@ -385,7 +396,7 @@ module ActionView
value = value(object)
content_tag("select",
add_options(
- time_zone_options_for_select(value, priority_zones, options[:model] || TimeZone),
+ time_zone_options_for_select(value || options[:default], priority_zones, options[:model] || TimeZone),
options, value
), html_options
)