ActionView::Helpers::FormHelper
def week_field(object_name, method, options = {})

Description

Creates an <input> with type="week" for a model attribute.

Arguments

Changing a value updates the ERB and HTML.

object_name:task
method:due_week
options= {}
Date.new(2026, 11, 4)
With a Date or Time, adds min in YYYY-Www format (such as 2000-W05). A string is first parsed as a date with DateTime.parse, then formatted the same way. Week strings such as "2000-W05" can also be parsed. If parsing fails, min is omitted. Around the new year, the year is the ISO 8601 week-numbering year, which can differ from the calendar year (2021-01-01 is 2020-W53).
"2026-11-18"
Adds max, formatted the same way as the :min option. This example uses a string.
Date.new(2026, 11, 11)
A Date or Time is formatted as YYYY-Www. Unlike with the :min and :max options, a string is not parsed and is used as is. Takes precedence over the object's value. Defaults to the object's value, formatted the same way. As with the :min option, the year is the week-numbering year.
Common options

Rails handles these options the same way in every helper. Options the HTML spec does not allow on the <input type="week">, and ones this site considers rarely used, are not listed here.

Shared by form helpers

"q"
Replaces the generated name with the given value. nil omits name.
nil
Replaces the generated id with the given value. nil omits id.

Shared by all helpers

true adds disabled="disabled"; false omits it. The same goes for every HTML attribute in Rails' list (BOOLEAN_ATTRIBUTES), such as readonly, required and autofocus: any value other than false or nil adds it as attr="attr".
{active: true, hidden: false}
A hash gives the keys whose values are not false or nil, joined with spaces. An array gives its elements joined with spaces, after removing nil, false and empty strings (including whitespace-only strings).
{controller: "tags", tags_suggestions_value: ["ruby", "rails"]}
A hash adds data-* attributes, with _ in the keys converted to -. Array and hash values are converted to JSON strings.
{describedby: ["name_help", "name_error"], invalid: false}
Like :data, adds aria-* attributes. Array values are joined with spaces, leaving out nil and empty strings (nothing is added if none remain). For a hash value, the keys whose values are not false or nil are joined with spaces.
Any other options become HTML attributes of the <input type="week">; those with a nil value are left out.

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