diff options
author | Colin Burn-Murdoch <colin@burn-murdoch.com> | 2013-01-14 17:55:45 +0000 |
---|---|---|
committer | Colin Burn-Murdoch <colin@burn-murdoch.com> | 2013-01-14 19:49:07 +0000 |
commit | 1fecaf15d779151defecf3eadda2b4524f7f5703 (patch) | |
tree | 44e26400470b3a6aa0dce8935ddb720a1612896c /actionpack/lib/action_view | |
parent | aea3820261c5bba9afcc775bf78d997e43db42f0 (diff) | |
download | rails-1fecaf15d779151defecf3eadda2b4524f7f5703.tar.gz rails-1fecaf15d779151defecf3eadda2b4524f7f5703.tar.bz2 rails-1fecaf15d779151defecf3eadda2b4524f7f5703.zip |
Rename :value option to :selected, in line with other select helpers
Add tests for time & datetime.
Add documentation.
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/date_helper.rb | 5 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/tags/date_select.rb | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb index 1fbf61a5a9..cf978d8e83 100644 --- a/actionpack/lib/action_view/helpers/date_helper.rb +++ b/actionpack/lib/action_view/helpers/date_helper.rb @@ -193,6 +193,7 @@ module ActionView # * <tt>:include_blank</tt> - Include a blank option in every select field so it's possible to set empty # dates. # * <tt>:default</tt> - Set a default date if the affected date isn't set or is nil. + # * <tt>:selected</tt> - Set a date that overrides the actual value. # * <tt>:disabled</tt> - Set to true if you want show the select fields as disabled. # * <tt>:prompt</tt> - Set to true (for a generic prompt), a prompt string or a hash of prompt strings # for <tt>:year</tt>, <tt>:month</tt>, <tt>:day</tt>, <tt>:hour</tt>, <tt>:minute</tt> and <tt>:second</tt>. @@ -234,6 +235,10 @@ module ActionView # # which is initially set to the date 3 days from the current date # date_select("article", "written_on", default: 3.days.from_now) # + # # Generates a date select that when POSTed is stored in the article variable, in the written_on attribute + # # which is set in the form with todays date, regardless of the value in the Active Record object. + # date_select("article", "written_on", selected: Date.today) + # # # Generates a date select that when POSTed is stored in the credit_card variable, in the bill_due attribute # # that will have a default day of 20. # date_select("credit_card", "bill_due", default: { day: 20 }) diff --git a/actionpack/lib/action_view/helpers/tags/date_select.rb b/actionpack/lib/action_view/helpers/tags/date_select.rb index f073c63f73..380d6d3686 100644 --- a/actionpack/lib/action_view/helpers/tags/date_select.rb +++ b/actionpack/lib/action_view/helpers/tags/date_select.rb @@ -27,7 +27,7 @@ module ActionView end def datetime_selector(options, html_options) - datetime = options[:value] || value(object) || default_datetime(options) + datetime = options[:selected] || value(object) || default_datetime(options) @auto_index ||= nil options = options.dup |