instance method datetime_select

Ruby on Rails 2.2.3

Since v2.2.3

Available in: v2.2.3 v2.3.18 v3.0.20 v3.1.12 v3.2.22.5 v4.0.13 v4.1.16 v4.2.9 v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

datetime_select(object_name, method, options = {}, html_options = {})

Returns a set of select tags (one for year, month, day, hour, and minute) pre-selected for accessing a specified datetime-based attribute (identified by method) on an object assigned to the template (identified by object). Examples:

If anything is passed in the html_options hash it will be applied to every select tag in the set.

Examples

# Generates a datetime select that, when POSTed, will be stored in the post variable in the written_on
# attribute
datetime_select("post", "written_on")

# Generates a datetime select with a year select that starts at 1995 that, when POSTed, will be stored in the
# post variable in the written_on attribute.
datetime_select("post", "written_on", :start_year => 1995)

# Generates a datetime select with a default value of 3 days from the current time that, when POSTed, will
# be stored in the trip variable in the departing attribute.
datetime_select("trip", "departing", :default => 3.days.from_now)

# Generates a datetime select that discards the type that, when POSTed, will be stored in the post variable
# as the written_on attribute.
datetime_select("post", "written_on", :discard_type => true)

The selects are prepared for multi-parameter assignment to an Active Record object.

Parameters

object_name req
method req
options opt = {}
html_options opt = {}
Source
# File actionpack/lib/action_view/helpers/date_helper.rb, line 245
      def datetime_select(object_name, method, options = {}, html_options = {})
        InstanceTag.new(object_name, method, self, options.delete(:object)).to_datetime_select_tag(options, html_options)
      end

Defined in actionpack/lib/action_view/helpers/date_helper.rb line 245 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionView::Helpers::DateHelper

Type at least 2 characters to search.

↑↓ navigate · open · esc close