From 04f9b8fe0735b22804d19a37719d1e65175b3e2b Mon Sep 17 00:00:00 2001 From: bogdanvlviv Date: Fri, 22 Jun 2018 00:48:20 +0300 Subject: Add to docs mention about `:year_format` option of date select Follow up #32190 [ci skip] --- actionview/lib/action_view/helpers/date_helper.rb | 4 ++++ 1 file changed, 4 insertions(+) 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 # * :end_year - Set the end year for the year select. Default is Date.today.year + 5 if # you are creating new record. While editing existing record, :end_year defaults to # the current selected year plus 5. + # * :year_format - Set format of years for year select. Lambda should be passed. # * :discard_day - 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 -- cgit v1.2.3