ActionView::Helpers::FormOptionsHelper

weekday_options_for_select

API docs (Rails 8.1.4.1) ↗
def weekday_options_for_select(selected = nil, index_as_value: false, day_format: :day_names, beginning_of_week: Date.beginning_of_week)

Description

Creates <option> elements for the days of the week.

Arguments

Changing a value updates the ERB and HTML.

= nil
Adds selected to the <option> whose value matches the given value. When index_as_value is true, pass the day number.
= false
true
true uses the day number instead of its name as the value of each <option> (Sunday is 0, Monday is 1). By default, the value is also the translated day name (date.day_names), so it changes with the page's language: Monday from Rails' built-in English locale, or the name from the app's locale files in other languages (月曜日 on this site's Japanese pages).
= :day_names
:abbr_day_names
The key under date. whose translation is used as the text of each <option>: :day_names (Monday) or :abbr_day_names (Mon). Unless index_as_value is true, the value uses the same name.
= Date.beginning_of_week
The day to start the list from. Defaults to Date.beginning_of_week (:monday in this app).

ERB

Changes from the previous output: Added Removed Changed


          

HTML


          

Preview

Interacting with the preview updates the form submission.

Form submission

Form data

namevalue
Request body

Content-Type:


              

params