how to control the format of rails select_date?
Currently,开发者_如何转开发 a date picker is shown by:
<%= select_date @blog.date, :use_short_month => true %>
it is shown as 3 drop down lists, example:
[2009] [Jun] [4]
how can I change the [yyyy] [mmm] [d]
sequence to [d] [mmm] [yyyy]
dynamically when the form loads? So it looks like:
[4] [Jun] [2009]
Note: changes required to be done in environment.rb
is considered too static.
Just in case someone stumbles into this select_date
order in rails problem during rails 5.0, I am providing this working solution below:
Adding class
to a rails select_date
form helper while also configuring the order format.
select_date(date = Date.current, options = {:order => [:month, :day, :year]}, html_options = { class: 'form-control form-control-lg' })
select_date(my_date, :order => [:day, :month, :year])
You can pass the :order
option to the tag.
EG:
<% select_date @blog.date, :order => [:year, :month, :day] %>
精彩评论