datetime_select(object_name, method, options = {}, html_options = {})
Instance Public methods
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
).
If anything is passed in the html_options hash it will be applied to every select tag in the set.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # Generates a datetime select that, when POSTed, will be stored in the article variable in the written_on # attribute. datetime_select( "article" , "written_on" ) # Generates a datetime select with a year select that starts at 1995 that, when POSTed, will be stored in the # article variable in the written_on attribute. datetime_select( "article" , "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) # Generate a datetime select with hours in the AM/PM format datetime_select( "article" , "written_on" , ampm: true ) # Generates a datetime select that discards the type that, when POSTed, will be stored in the article variable # as the written_on attribute. datetime_select( "article" , "written_on" , discard_type: true ) # Generates a datetime select with a custom prompt. Use <tt>prompt: true</tt> for generic prompts. datetime_select( "article" , "written_on" , prompt: {day: 'Choose day' , month: 'Choose month' , year: 'Choose year' }) datetime_select( "article" , "written_on" , prompt: {hour: true }) # generic prompt for hours datetime_select( "article" , "written_on" , prompt: true ) # generic prompts for all |
The selects are prepared for multi-parameter assignment to an Active Record object.
Please login to continue.