Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

beefed up documentation for :date|:time|:datetime inputs

  • Loading branch information...
commit b21a6371837aa0e50ca2fcd4d3fcba660e4b402c 1 parent b872f39
@justinfrench justinfrench authored
Showing with 20 additions and 7 deletions.
  1. +20 −7 lib/formtastic.rb
View
27 lib/formtastic.rb
@@ -867,8 +867,8 @@ def radio_input(method, options)
# f.input :created_at, :as => :date, :selected => 1.day.ago
# f.input :created_at, :as => :date, :selected => nil # override any defaults: select none
#
- # Some of Rails' options for select_date are supported, but not everything yet.
- #
+ # Some of Rails' options for select_date are supported, but not everything yet, see
+ # documentation of date_or_datetime_input() for more information.
def date_input(method, options)
options = set_include_blank(options)
date_or_datetime_input(method, options.merge(:discard_hour => true))
@@ -886,8 +886,8 @@ def date_input(method, options)
# f.input :created_at, :as => :datetime, :selected => 1.day.ago
# f.input :created_at, :as => :datetime, :selected => nil # override any defaults: select none
#
- # Some of Rails' options for select_date are supported, but not everything yet.
- #
+ # Some of Rails' options for select_date are supported, but not everything yet, see
+ # documentation of date_or_datetime_input() for more information.
def datetime_input(method, options)
options = set_include_blank(options)
date_or_datetime_input(method, options)
@@ -904,13 +904,17 @@ def datetime_input(method, options)
# f.input :created_at, :as => :time, :selected => 1.hour.ago
# f.input :created_at, :as => :time, :selected => nil # override any defaults: select none
#
- # Some of Rails' options for select_time are supported, but not everything yet.
- #
+ # Some of Rails' options for select_time are supported, but not everything yet, see
+ # documentation of date_or_datetime_input() for more information.
def time_input(method, options)
options = set_include_blank(options)
date_or_datetime_input(method, options.merge(:discard_year => true, :discard_month => true, :discard_day => true))
end
-
+
+ # Helper method used by :as => (:date|:datetime|:time). Generates a fieldset containing a
+ # legend (for what would normally be considered the label), and an ordered list of list items
+ # for year, month, day, hour, etc, each containing a label and a select. Example:
+ #
# <fieldset>
# <legend>Created At</legend>
# <ol>
@@ -943,6 +947,15 @@ def time_input(method, options)
#
# This is an absolute abomination, but so is the official Rails select_date().
#
+ # Options:
+ #
+ # * @:order => [:month, :day, :year]@
+ # * @:include_seconds@ => true@
+ # * @:selected => Time.mktime(2008)@
+ # * @:selected => Date.new(2008)@
+ # * @:selected => nil@
+ # * @:discard_(year|month|day|hour|minute) => true@
+ # * @:include_blank => true@
def date_or_datetime_input(method, options)
position = { :year => 1, :month => 2, :day => 3, :hour => 4, :minute => 5, :second => 6 }
i18n_date_order = ::I18n.t(:order, :scope => [:date])
Please sign in to comment.
Something went wrong with that request. Please try again.