未验证 提交 0a6b866f 编写于 作者: P Prem Sichanugrist 提交者: GitHub

Merge pull request #33184 from bogdanvlviv/document-year_format-option-of-date_select

Add to docs mention about `:year_format` option of date select
...@@ -205,6 +205,7 @@ def time_ago_in_words(from_time, options = {}) ...@@ -205,6 +205,7 @@ def time_ago_in_words(from_time, options = {})
# * <tt>:end_year</tt> - Set the end year for the year select. Default is <tt>Date.today.year + 5</tt> if # * <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 # you are creating new record. While editing existing record, <tt>:end_year</tt> defaults to
# the current selected year plus 5. # 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 # * <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 # 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. # first of the given month in order to not create invalid dates like 31 February.
...@@ -275,6 +276,9 @@ def time_ago_in_words(from_time, options = {}) ...@@ -275,6 +276,9 @@ def time_ago_in_words(from_time, options = {})
# # Generates a date select with custom prompts. # # Generates a date select with custom prompts.
# date_select("article", "written_on", prompt: { day: 'Select day', month: 'Select month', year: 'Select year' }) # 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. # 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 # 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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册