开发者

how to control the format of rails select_date?

开发者 https://www.devze.com 2023-01-02 18:49 出处:网络
Currently,开发者_如何转开发 a date picker is shown by: <%= select_date @blog.date, :use_short_month => true %>

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] %>
0

精彩评论

暂无评论...
验证码 换一张
取 消