1

Add `beginning_of_week` option to `weekday_options_for_select` by DRBragg · Pull...

 2 years ago
source link: https://github.com/rails/rails/pull/43037
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Copy link

Contributor

DRBragg commented on Aug 17

Summary

In #42979 the suggestion was made to include an option to allow users to set "Monday" as the first day on the list.

weekday_options_for_select(begin_on_monday: true)
# => "<option value=\"Monday\">Monday</option>\n<option value=\"Tuesday\">Tuesday</option>\n
# <option value=\"Wednesday\">Wednesday</option>\n<option value=\"Thursday\">Thursday</option>\n
# <option value=\"Friday\">Friday</option>\n<option value=\"Saturday\">Saturday</option>\n
# <option value=\"Sunday\">Sunday</option>"

NOTE: If you are using indexes as values Sundays value will remain 0 for consistency with Ruby and the I18n day names array.

weekday_options_for_select(begin_on_monday: true, index_as_value: true)
# => "<option value=\"1\">Monday</option>\n<option value=\"2\">Tuesday</option>\n
# <option value=\"3\">Wednesday</option>\n<option value=\"4\">Thursday</option>\n
# <option value=\"5\">Friday</option>\n<option value=\"6\">Saturday</option>\n
# <option value=\"0\">Sunday</option>"

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK