Add data- attribute to time_select element?
jaredlt opened this issue · comments
Hi, is it possible to add a data attribute to the time_select element?
Eg. <select data-input="true">
I have tried the following but it doesn't seem to work:
<%= form.time_select :time_start,
combined: true,
minute_interval: 30,
ampm: true,
time_separator: "",
end_hour: 23,
include_blank: true,
data: { input: "true" } # tried adding at the end here
%>
Ah, I was not clarifying the options
vs html_options
🤦♂️
Ref: https://www.rubydoc.info/gems/actionview/ActionView/Helpers/DateTimeSelector
#initialize(datetime, options = {}, html_options = {})
For future users, the correct format is:
<%= form.time_select :time_start, # :time_start here is the datetime object
{
combined: true,
minute_interval: 30,
ampm: true,
time_separator: "",
end_hour: 23,
include_blank: true
}, # options
{
data: { input: "true" }
} # html_options
%>
@jaredlt 👍 that's caught me several times. We can update the readme to include an example for anyone else who is looking for that too.