method
select_date
v3.0.0 -
Show latest stable
-
1 note -
Class: ActionView::Helpers::DateHelper
- 1.0.0 (0)
- 1.1.6 (0)
- 1.2.6 (12)
- 2.0.3 (38)
- 2.1.0 (4)
- 2.2.1 (6)
- 2.3.8 (15)
- 3.0.0 (0)
- 3.0.9 (-3)
- 3.1.0 (2)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (-2)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- 7.2.3 (0)
- 8.0.0 (0)
- 8.1.1 (0)
- What's this?
select_date(date = Date.current, options = {}, html_options = {})
public
Returns a set of html select-tags (one for year, month, and day) pre-selected with the date. It’s possible to explicitly set the order of the tags using the :order option with an array of symbols :year, :month and :day in the desired order. If you do not supply a Symbol, it will be appended onto the :order passed in.
If anything is passed in the html_options hash it will be applied to every select tag in the set.
Examples
my_date = Time.today + 6.days # Generates a date select that defaults to the date in my_date (six days after today) select_date(my_date) # Generates a date select that defaults to today (no specified date) select_date() # Generates a date select that defaults to the date in my_date (six days after today) # with the fields ordered year, month, day rather than month, day, year. select_date(my_date, :order => [:year, :month, :day]) # Generates a date select that discards the type of the field and defaults to the date in # my_date (six days after today) select_date(my_date, :discard_type => true) # Generates a date select that defaults to the date in my_date, # which has fields separated by '/' select_date(my_date, :date_separator => '/') # Generates a date select that defaults to the datetime in my_date (six days after today) # prefixed with 'payday' rather than 'date' select_date(my_date, :prefix => 'payday') # Generates a date select with a custom prompt. Use :prompt=>true for generic prompts. select_date(my_date, :prompt => {:day => 'Choose day', :month => 'Choose month', :year => 'Choose year'}) select_date(my_date, :prompt => {:hour => true}) # generic prompt for hours select_date(my_date, :prompt => true) # generic prompts for all
Register or
log in
to add new notes.
hechien -
January 28, 2016
0 thanks
the method to make 'day' disappear.
If you wanna show “year” and “month” only, you can use “order” to do it:
select_date(Date.current, order: [:year, :month])
That’s it.

