diff options
author | Evan Tann <egtann@gmail.com> | 2012-08-12 15:53:54 -0400 |
---|---|---|
committer | Evan Tann <egtann@gmail.com> | 2012-08-13 12:26:23 -0400 |
commit | 1edc7cd78b8f232107eb8565b7a9757ea8062c44 (patch) | |
tree | c934872e740210e3f7b383da0339cc2adef09062 /actionpack/lib/action_view/helpers | |
parent | 1ce64095e418f19f0792fa84156430921cb6c1f1 (diff) | |
download | rails-1edc7cd78b8f232107eb8565b7a9757ea8062c44.tar.gz rails-1edc7cd78b8f232107eb8565b7a9757ea8062c44.tar.bz2 rails-1edc7cd78b8f232107eb8565b7a9757ea8062c44.zip |
Add support for start_hour and end_hour options in select_hour helper
Updated documentation to demonstrate start_hour and end_hour options
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r-- | actionpack/lib/action_view/helpers/date_helper.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb index 659aacf6d7..dea2aa69dd 100644 --- a/actionpack/lib/action_view/helpers/date_helper.rb +++ b/actionpack/lib/action_view/helpers/date_helper.rb @@ -427,6 +427,9 @@ module ActionView # # Generate a time select field with hours in the AM/PM format # select_time(my_time, :ampm => true) # + # # Generates a time select field with hours that range from 2 to 14 + # select_time(my_time, :start_hour => 2, :end_hour => 14) + # # # Generates a time select with a custom prompt. Use <tt>:prompt</tt> to true for generic prompts. # select_time(my_time, :prompt => {:day => 'Choose day', :month => 'Choose month', :year => 'Choose year'}) # select_time(my_time, :prompt => {:hour => true}) # generic prompt for hours @@ -504,6 +507,9 @@ module ActionView # # # Generate a select field for hours in the AM/PM format # select_hour(my_time, :ampm => true) + # + # # Generates a select field that includes options for hours from 2 to 14. + # select_hour(my_time, :start_hour => 2, :end_hour => 14) def select_hour(datetime, options = {}, html_options = {}) DateTimeSelector.new(datetime, options, html_options).select_hour end @@ -734,7 +740,11 @@ module ActionView if @options[:use_hidden] || @options[:discard_hour] build_hidden(:hour, hour) else - build_options_and_select(:hour, hour, :end => 23, :ampm => @options[:ampm]) + options = {} + options[:ampm] = @options[:ampm] || false + options[:start] = @options[:start_hour] || 0 + options[:end] = @options[:end_hour] || 23 + build_options_and_select(:hour, hour, options) end end |