I have the following date_select helper. I want to add a class but it's not producing the HTML.
<%= date_select :recipient, :birthday, :order => [:day, :month, :year], :start_year => 1920, :end_year => 2013, :class => "input-mini" %>
I've also tried it with a hash as some solutions suggest but I get a syntax error:
<%= date_select :recipient, :birthday, :order => [:day, :month, :year], :start_year => 1920, :end_year => 2013, {:class => "input-mini"} %>
Not sure I really understand when and how to format it with a hash.
The validated answer did not work for me, what worked was:
<%= date_select
:recipient,
:birthday,
{:order => [:day, :month, :year], :start_year => 1920, :end_year => 2013},
{:class => "input-mini"}
%>
Which makes more sense according to the docs:
date_select(object_name, method, options = {}, html_options = {})
This should work:
<%= date_select :recipient, :birthday,
:order => [:day, :month, :year],
:start_year => 1920,
:end_year => 2013,
:html=>{:class => "input-mini"}
%>
Update: For Rails 5
<%= date_select :recipient, :birthday,
{
:order => [:day, :month, :year],
:start_year => 1920,
:end_year => 2013
},
{:class => "input-mini"} %>
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