0
votes

I would like to change the month select input from date_select : change the values of the array (with January, February... to Janvier, Février...). And I would also like to append styling to each select box (day, month and year). This is my date_select

<%= f.date_select :birthdate, 
                 order: [:day, :month, :year],
                 prompt: { day: 'Jour', month: 'Mois', year: 'Année' }, 
                 start_year: Date.today.year - 13,
                 end_year: Date.today.year - 100 
%>

I don't seem to find anything on the rails official documentation. Any help? Thanks :)

3
Date.today.year - 13 == 13.years.ago.yearSebastian Palma
And it don't discriminate against people over 100 just because its unlikely.max

3 Answers

1
votes

I guess below code would help you.

<%= f.date_select :birthdate,
                 {
                 order: [:day, :month, :year],
                 prompt: { day: 'Jour', month: 'Mois', year: 'Année' }, 
                 start_year: Date.today.year - 13,
                 end_year: Date.today.year - 100,
                 locale: :fr
                 },
                {class: 'custom-style'}

%>
0
votes

I guess setting f.date_select ... locale: :fr will help

0
votes

Use the use_month_names option to set custom values for the months:

<%= f.date_select :birthdate, 
      {
        order: [:day, :month, :year],
        prompt: { day: 'Jour', month: 'Mois', year: 'Année' }, 
        start_year: Date.today.year - 13,
        end_year: Date.today.year - 100,
        use_month_names: ["Janvier", "Février", etc..]
       },
       { class: "some-css-class-for-styling" }
%>