Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formatting Date with Simple Form

I'm using the Simple Form gem in my Rails app. In my sign-up form, I'm have a field for birth date. However, the fields are showing in this order: Year/Month/Day.

What's the best way to get the field order Month - Day - Year?

My form looks like this:

 <%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
   <%= f.input :created_at %>          
   <%= f.button :submit, "Sign up" %>      
<% end %>
like image 542
yellowreign Avatar asked Dec 08 '22 19:12

yellowreign


2 Answers

Are you looking for this?

<%= f.input :birthday, :order => [:month, :day, :year] %>
like image 72
Hachi Avatar answered Jan 12 '23 20:01

Hachi


I don't know if it will work with simple_form, but I suspect it will... Add the following to config/locals/en.yml (or similar):

en:
  date:
    order:
      - :month
      - :day
      - :year
like image 29
Philip Hallstrom Avatar answered Jan 12 '23 19:01

Philip Hallstrom