Skip to content

Commit

Permalink
Add helper text to datetime-local form fields
Browse files Browse the repository at this point in the history
Currently, datetime form fields are ambiguous because it's unclear whether
the application timezone or system timezone will be used. This commit
adds helper text to datetime form fields specifying that the system
timezone will be used for datetime-local parameter inputs.
  • Loading branch information
adrianna-chang-shopify committed Jun 1, 2023
1 parent 5d3294c commit 91727c3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/helpers/maintenance_tasks/tasks_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def parameter_field(form_builder, parameter_name)
when ActiveModel::Type::Decimal, ActiveModel::Type::Float
form_builder.number_field(parameter_name, { step: "any" })
when ActiveModel::Type::DateTime
form_builder.datetime_field(parameter_name)
form_builder.datetime_field(parameter_name) + datetime_field_help_text
when ActiveModel::Type::Date
form_builder.date_field(parameter_name)
when ActiveModel::Type::Time
Expand All @@ -120,5 +120,13 @@ def parameter_field(form_builder, parameter_name)
form_builder.text_area(parameter_name, class: "textarea")
end
end

# Return helper text for the datetime-local form field.
def datetime_field_help_text
tag.div(
tag.p("Datetime inputs will use the system timezone, which is #{Time.now.zone}."),
class: "content is-small",
)
end
end
end

0 comments on commit 91727c3

Please sign in to comment.