diff options
author | Steve Klabnik <steve@steveklabnik.com> | 2013-01-14 12:18:36 -0800 |
---|---|---|
committer | Steve Klabnik <steve@steveklabnik.com> | 2013-01-14 12:18:36 -0800 |
commit | 1dd89250d12aba01d605af270201371e5cec89a4 (patch) | |
tree | cd2310f0f9bdaf6d6166f2eae6f1bdd921a116c9 /actionpack/lib/action_view | |
parent | bf095770e561c51cebeb5a556afc03a21d9e603c (diff) | |
parent | 1fecaf15d779151defecf3eadda2b4524f7f5703 (diff) | |
download | rails-1dd89250d12aba01d605af270201371e5cec89a4.tar.gz rails-1dd89250d12aba01d605af270201371e5cec89a4.tar.bz2 rails-1dd89250d12aba01d605af270201371e5cec89a4.zip |
Merge pull request #8938 from colinbm/date_select_value
Rename :value to :selected for date_select, and add missing tests/docs
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 |