Joh*_*ohn 2 css format datetime ruby-on-rails twitter-bootstrap
我在我的表中有一个日期时间字段,在用户视图中选择我使用 datetime_select 视图助手的日期时间。我想用引导程序类来设置它的样式,我不想要它显示的默认日期格式。如何格式化此日期时间选择以及如何设置此字段的样式?
这是我现在使用的代码。
<%= f.datetime_select :check_out_req , ampm: true , :class => "form-control"%>
Run Code Online (Sandbox Code Playgroud)
它以格式显示日期时间选择下拉列表year,month, date,hours, minutes。但我希望它以格式显示下拉列表day,month,year,hours,minutes。
当我应用这样:class => "form-control"的样式时,样式不是 applyig。如何设计这个领域?
该datetime_select方法有两个哈希值,一个是options和一个html_options。您需要明确地告诉 Ruby 哪些键属于哪个散列。由于ampm属于options散列并且class属于html_options散列,因此您需要将散列分开。此外,如果您想对下拉菜单重新排序,请提供以下order选项:
<%= f.datetime_select :check_out_req, { ampm: true, order: [:day, :month, :year] }, { class: "form-control" } %>
Run Code Online (Sandbox Code Playgroud)