# CSS attributes for date\_select

**URL:** <https://www.ruby-forum.com/t/css-attributes-for-date-select/109020>\
**Category:** Rails\
**Created:** [July 10, 2007, 6:09pm UTC](https://www.ruby-forum.com/t/css-attributes-for-date-select/109020 "2007-07-10T18:09:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gattox](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/4491bb/32.png) [@gattox](https://www.ruby-forum.com/u/gattox)\
**Post date:** [July 10, 2007, 6:09pm UTC](https://www.ruby-forum.com/t/css-attributes-for-date-select/109020/1 "2007-07-10T18:09:32Z")

</div>

How can I specify a CSS attribute for date\_select?

If I write for example:

\<%= date\_select ‘study’, ‘data\_on’, :order =\> [:day, :month, :year],  
:start\_year =\> 1940, :end\_year =\> Time.now.year, :class =\> “mandatory”  
%\>

and then look at the generated HTML, I find no evidence of the CSS  
attribute.

Any help appreciated.

---

<div class="post-metadata">

**Author:** ![gattox](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/4491bb/32.png) [@gattox](https://www.ruby-forum.com/u/gattox)\
**Post date:** [July 10, 2007, 8:08pm UTC](https://www.ruby-forum.com/t/css-attributes-for-date-select/109020/2 "2007-07-10T20:08:47Z")

</div>

On Jul 10, 2007, at 11:09 , Roberto Gattinoni wrote:

> How can I specify a CSS attribute for date\_select?

I don’t believe date\_select provides for HTML options. What would it  
mean? Apply the same class=“mandatory” to each of the three generated  
s? I’d put the class attribute in the parent element of the  
date\_select.

Michael G.  
grzm seespotcode net

---

<div class="post-metadata">

**Author:** ![gattox](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/4491bb/32.png) [@gattox](https://www.ruby-forum.com/u/gattox)\
**Post date:** [July 10, 2007, 8:18pm UTC](https://www.ruby-forum.com/t/css-attributes-for-date-select/109020/3 "2007-07-10T20:18:48Z")

</div>

Hi Roberto,

Looks like date\_select doesn’t take any html\_options as a parameter  
except in edge rails.

[http://dev.rubyonrails.org/ticket/6000](http://dev.rubyonrails.org/ticket/6000)  
\<[http://api.rubyonrails.org/classes/ActionView/Helpers/](http://api.rubyonrails.org/classes/ActionView/Helpers/)  
DateHelper.html#M000577\>

Brad.

On Jul 10, 12:09 pm, Roberto Gattinoni \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![gattox](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/4491bb/32.png) [@gattox](https://www.ruby-forum.com/u/gattox)\
**Post date:** [July 11, 2007, 7:57am UTC](https://www.ruby-forum.com/t/css-attributes-for-date-select/109020/4 "2007-07-11T07:57:49Z")

</div>

Michael G. wrote:

> On Jul 10, 2007, at 11:09 , Roberto Gattinoni wrote:
> 
> > How can I specify a CSS attribute for date\_select?
> 
> I don’t believe date\_select provides for HTML options. What would it  
> mean? Apply the same class=“mandatory” to each of the three generated  
> s? I’d put the class attribute in the parent element of the  
> date\_select.
> 
> Michael G.  
> grzm seespotcode net

Not the same thing: try to apply a background-color attribute to the  
parent element of a SELECT.

Roberto Gattinoni.

---

<div class="post-metadata">

**Author:** ![gattox](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/4491bb/32.png) [@gattox](https://www.ruby-forum.com/u/gattox)\
**Post date:** [July 11, 2007, 3:56pm UTC](https://www.ruby-forum.com/t/css-attributes-for-date-select/109020/5 "2007-07-11T15:56:54Z")

</div>

On Jul 11, 2007, at 0:57 , Roberto Gattinoni wrote:

> > Michael G.  
> > grzm seespotcode net
> 
> Not the same thing: try to apply a background-color attribute to the  
> parent element of a SELECT.

You mean you want to set the background-color of the select rather  
then the select’s parent element, correct?

HTML fragment:

bar baz

CSS:  
p.mandatory select { background-color: red }

Michael G.  
grzm seespotcode net

---

<div class="post-metadata">

**Author:** ![gattox](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/4491bb/32.png) [@gattox](https://www.ruby-forum.com/u/gattox)\
**Post date:** [July 11, 2007, 4:16pm UTC](https://www.ruby-forum.com/t/css-attributes-for-date-select/109020/6 "2007-07-11T16:16:19Z")

</div>

Michael G. wrote:

> On Jul 11, 2007, at 0:57 , Roberto Gattinoni wrote:
> 
> > > Michael G.  
> > > grzm seespotcode net
> > 
> > Not the same thing: try to apply a background-color attribute to the  
> > parent element of a SELECT.
> 
> You mean you want to set the background-color of the select rather  
> then the select’s parent element, correct?
> 
> HTML fragment:
> 
> bar baz
> 
> CSS:  
> p.mandatory select { background-color: red }
> 
> Michael G.  
> grzm seespotcode net

… sounds good (better a cause

is a block-level element and  
forces a new-line).

Thanks for the suggestion.  
Roberto Gattinoni.

---

<div class="post-metadata">

**Author:** ![gattox](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/4491bb/32.png) [@gattox](https://www.ruby-forum.com/u/gattox)\
**Post date:** [July 10, 2007, 8:32pm UTC](https://www.ruby-forum.com/t/css-attributes-for-date-select/109020/7 "2007-07-10T20:32:53Z")

</div>

On Jul 10, 2007, at 13:18 , Brad C. wrote:

> Looks like date\_select doesn’t take any html\_options as a parameter  
> except in edge rails.
> 
> [http://dev.rubyonrails.org/ticket/6000](http://dev.rubyonrails.org/ticket/6000)

The ticket is still open: this hasn’t been applied and therefore  
isn’t in Edge.

Michael G.  
grzm seespotcode net

---

<div class="post-metadata">

**Author:** ![gattox](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/4491bb/32.png) [@gattox](https://www.ruby-forum.com/u/gattox)\
**Post date:** [July 11, 2007, 5:15pm UTC](https://www.ruby-forum.com/t/css-attributes-for-date-select/109020/8 "2007-07-11T17:15:12Z")

</div>

On Jul 11, 2007, at 9:16 , Roberto Gattinoni wrote:

> … sounds good (better a cause
> 
> is a block-level element  
> and  
> forces a new-line).

p.mandatory { display:inline }

Michael G.  
grzm seespotcode net
