您好我正在尝试制作一个date_select,该类不会生效。感谢您的帮助。
<%= f.date_select :created_at,
:order => [:month, :day, :year],
:prompt => {month: 'Birth Month', day: 'Birth Day', year: 'Birth Year'},
:start_year => Time.now.year,
:end_year => 1920,
:class => 'SelectDropDown' %>
答案 0 :(得分:0)
我喜欢的表单助手叫做simple_form。当我需要添加日期选择器时,我一直在使用bootstrap3-datetimepicker-rails
设定:
文件#app / assets / javascripts / application.js
$(document).ready(function() {
$('.datetimepicker').datetimepicker({});
return $('.datepicker').datetimepicker({
format: 'YYYY/MM/DD'
});
});
});
现在将其应用于表单
= f.input:date_select,as :: string,input_html:{class:'datetimepicker',value:“#{f.created_at}”}
我希望这有助于
答案 1 :(得分:0)
尝试在课堂上使用html_options:
<%= f.date_select :created_at,
order: [:month, :day, :year],
prompt: {month: 'Birth Month', day: 'Birth Day', year: 'Birth Year'},
start_year: Time.now.year,
end_year: 1920,
html_options: {class: "SelectDropDown"} %>
有关详情,请查看data_select