Method: ActionView::Helpers::FormOptionsHelper#time_zone_select

Defined in:
lib/action_view/helpers/form_options_helper.rb

#time_zone_select(object, method, priority_zones = nil, options = {}, html_options = {}) ⇒ Object

Return select and option tags for the given object and method, using #time_zone_options_for_select to generate the list of option tags.

In addition to the :include_blank option documented above, this method also supports a :model option, which defaults to ActiveSupport::TimeZone. This may be used by users to specify a different time zone model object. (See time_zone_options_for_select for more information.)

You can also supply an array of ActiveSupport::TimeZone objects as priority_zones, so that they will be listed above the rest of the (long) list. (You can use ActiveSupport::TimeZone.us_zones as a convenience for obtaining a list of the US time zones, or a Regexp to select the zones of your choice)

Finally, this method supports a :default option, which selects a default ActiveSupport::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', ActiveSupport::TimeZone.us_zones, :default => "Pacific Time (US & Canada)")

time_zone_select( "user", 'time_zone', [ ActiveSupport::TimeZone['Alaska'], ActiveSupport::TimeZone['Hawaii'] ])

time_zone_select( "user", 'time_zone', /Australia/)

time_zone_select( "user", "time_zone", ActiveSupport::Timezone.all.sort, :model => ActiveSupport::Timezone)


251
252
253
# File 'lib/action_view/helpers/form_options_helper.rb', line 251

def time_zone_select(object, method, priority_zones = nil, options = {}, html_options = {})
  InstanceTag.new(object, method, self,  options.delete(:object)).to_time_zone_select_tag(priority_zones, options, html_options)
end