问题
In Rails' forms, date select
drop-downs are easy:
<%= f.label :my_date %>
<%= f.date_select :my_date %>
Then I get 3 select
drop-downs for the year, month and day. Is there an easy way to add HTML between these select
elements without using JavaScript? I want to be able to style and label them nicer.
回答1:
Convert it to a text field and add a JQuery datepicker or similar.
Theres a good guide here, http://railscasts.com/episodes/213-calendars
回答2:
You can easily style them with CSS as each part of date_select is postfixed with '_1i', '_2i' etc . For a date_select with id 'my_date' you can use
#my_date_1i // the year
#my_date_2i // the month
#my_date_3i // the day
Hope this helps
Cheers
来源:https://stackoverflow.com/questions/15860467/styling-the-date-fields-of-a-rails-date-select