# Date\_select - Specifying an id for each selector fails

**URL:** <https://www.ruby-forum.com/t/date-select-specifying-an-id-for-each-selector-fails/173439>\
**Category:** Rails\
**Created:** [August 8, 2009, 11:57pm UTC](https://www.ruby-forum.com/t/date-select-specifying-an-id-for-each-selector-fails/173439 "2009-08-08T23:57:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lb2007](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/35a633/32.png) [@Lb2007](https://www.ruby-forum.com/u/Lb2007)\
**Post date:** [August 8, 2009, 11:57pm UTC](https://www.ruby-forum.com/t/date-select-specifying-an-id-for-each-selector-fails/173439/1 "2009-08-08T23:57:59Z")

</div>

Because of some third party dependencies I’m trying to use a  
date\_select helper (actually datetime, but they behave the same)  
whilst specifying an ID for each of the three selectors (day/month/  
year).

\<%= f.date\_select :start, {:order =\> [:day, :month, :year]}, {:id =\>  
{:year =\> ‘abc’, :month =\> ‘de’, :day =\> ‘xy’}} %\>  
The code above nearly works; the right selectors are generated in the  
right order, however, the IDs of each selector are the same; simply a  
flattened down version ‘monthdeyearabcdayxy’, using an array has the  
same effect.

How can I achieve this while still having Rails handle most of the  
work?

---

<div class="post-metadata">

**Author:** ![Lb2007](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/35a633/32.png) [@Lb2007](https://www.ruby-forum.com/u/Lb2007)\
**Post date:** [August 9, 2009, 12:00am UTC](https://www.ruby-forum.com/t/date-select-specifying-an-id-for-each-selector-fails/173439/2 "2009-08-09T00:00:19Z")

</div>

On Aug 8, 9:41 pm, Lb2007 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> \<%= f.date\_select :start, {:order =\> [:day, :month, :year]}, {:id =\>  
> {:year =\> ‘abc’, :month =\> ‘de’, :day =\> ‘xy’}} %\>  
> The code above nearly works; the right selectors are generated in the  
> right order, however, the IDs of each selector are the same; simply a  
> flattened down version ‘monthdeyearabcdayxy’, using an array has the  
> same effect.
> 
> How can I achieve this while still having Rails handle most of the  
> work?  
> Your best bet is probably to call the individual helpers for each  
> component (select\_hour etc…). Look at the output of date\_select to  
> see what names you should use for the inputs.

Fred
