使用简单表单格式化日期

yel*_*ign 4 ruby-on-rails-3 simple-form

我在我的Rails应用程序中使用Simple Form gem.在我的注册表格中,我有一个出生日期字段.但是,字段按以下顺序显示:年/月/日.

什么是获得现场订单的最佳方式月 - 日 - 年?

我的表单看起来像这样:

 <%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
   <%= f.input :created_at %>          
   <%= f.button :submit, "Sign up" %>      
<% end %>
Run Code Online (Sandbox Code Playgroud)

小智 7

你在找这个吗?

<%= f.input :birthday, :order => [:month, :day, :year] %>
Run Code Online (Sandbox Code Playgroud)


Phi*_*rom 5

我不知道它是否适用于simple_form,但我怀疑它会...将以下内容添加到config/locals/en.yml(或类似):

en:
  date:
    order:
      - :month
      - :day
      - :year
Run Code Online (Sandbox Code Playgroud)