aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib
diff options
context:
space:
mode:
authorbogdanvlviv <bogdanvlviv@gmail.com>2018-06-22 00:48:20 +0300
committerbogdanvlviv <bogdanvlviv@gmail.com>2018-06-22 00:50:22 +0300
commit04f9b8fe0735b22804d19a37719d1e65175b3e2b (patch)
treedcf1a82a9ec6e9a2a9db0e521821e64dc0b72ffb /actionview/lib
parent4dd1eb27ef02704cbfc47b1ebe1ff94f294bf471 (diff)
downloadrails-04f9b8fe0735b22804d19a37719d1e65175b3e2b.tar.gz
rails-04f9b8fe0735b22804d19a37719d1e65175b3e2b.tar.bz2
rails-04f9b8fe0735b22804d19a37719d1e65175b3e2b.zip
Add to docs mention about `:year_format` option of date select
Follow up #32190 [ci skip]
Diffstat (limited to 'actionview/lib')
-rw-r--r--actionview/lib/action_view/helpers/date_helper.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/actionview/lib/action_view/helpers/date_helper.rb b/actionview/lib/action_view/helpers/date_helper.rb
index 1622b9f680..ae993f9aa2 100644
--- a/actionview/lib/action_view/helpers/date_helper.rb
+++ b/actionview/lib/action_view/helpers/date_helper.rb
@@ -205,6 +205,7 @@ module ActionView
# * <tt>:end_year</tt> - Set the end year for the year select. Default is <tt>Date.today.year + 5</tt> if
# you are creating new record. While editing existing record, <tt>:end_year</tt> defaults to
# the current selected year plus 5.
+ # * <tt>:year_format</tt> - Set format of years for year select. Lambda should be passed.
# * <tt>:discard_day</tt> - Set to true if you don't want to show a day select. This includes the day
# as a hidden field instead of showing a select field. Also note that this implicitly sets the day to be the
# first of the given month in order to not create invalid dates like 31 February.
@@ -275,6 +276,9 @@ module ActionView
# # Generates a date select with custom prompts.
# date_select("article", "written_on", prompt: { day: 'Select day', month: 'Select month', year: 'Select year' })
#
+ # # Generates a date select with custom year format.
+ # date_select("article", "written_on", year_format: ->(year) { "Heisei #{year - 1988}" })
+ #
# The selects are prepared for multi-parameter assignment to an Active Record object.
#
# Note: If the day is not included as an option but the month is, the day will be set to the 1st to ensure that