I have the following use of date_select..
<%= f.date_select :birthday, :order => [:month, :day], :prompt => { :day => 'Select day', :month => 'Select month' }, :html => {:class => "select birthday"} %>
But the class does not show up in the html..
<select id="profile_birthday_2i" name="profile[birthday(2i)]">
<select id="profile_birthday_3i" name="profile[birthday(3i)]">
I also tried..
<%= f.date_select :birthday, :order => [:month, :day], :prompt => { :day => 'Select day', :month => 'Select month' }, :class => "select birthday" %>
That did not work either. Any ideas?
The HTML options are a fourth argument to the date_select
method, rather than being a key in the third argument.
From the documentation:
date_select(object_name, method, options = {}, html_options = {})
So you'd want:
f.date_select :birthday, { :order => [:month, :day], :prompt => { :day => 'Select day', :month => 'Select month' } }, {:class => "select birthday"}
You need to use html_options
, not html
to specify the class.
I believe this will work, though I've not tested it.
<%= f.date_select :birthday, :order => [:month, :day], :prompt => { :day => 'Select day', :month => 'Select month' }, :html_options => {:class => "select birthday"} %>
See the API description here:
http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html
Note: The docs say:
If anything is passed in the html_options hash it will be applied to every select tag in the set.
So make sure you expect that class to show up on each element.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With