# Change field name of select\_day, select\_month

**URL:** <https://www.ruby-forum.com/t/change-field-name-of-select-day-select-month/183710>\
**Category:** Rails\
**Created:** [February 18, 2010, 11:01pm UTC](https://www.ruby-forum.com/t/change-field-name-of-select-day-select-month/183710 "2010-02-18T23:01:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ang89](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@ang89](https://www.ruby-forum.com/u/ang89)\
**Post date:** [February 18, 2010, 11:01pm UTC](https://www.ruby-forum.com/t/change-field-name-of-select-day-select-month/183710/1 "2010-02-18T23:01:23Z")

</div>

Hi there,

Functions like select\_day, select\_month, or select\_year by defaults have  
a field name of “date[day]”, “date[month]”, and “date[year]”  
respectively. Well, I want to change it to be as simply as “day”,  
“month”, and “year”. Do rails have a built in function to do that?

In the documentation, I found a :field\_name option, but it does not meet  
my need (the format is still “date[field\_name]”).

Regards,  
Ang

---

<div class="post-metadata">

**Author:** ![ang89](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@ang89](https://www.ruby-forum.com/u/ang89)\
**Post date:** [February 18, 2010, 11:33pm UTC](https://www.ruby-forum.com/t/change-field-name-of-select-day-select-month/183710/2 "2010-02-18T23:33:21Z")

</div>

Andree S. wrote:

> Functions like select\_day, select\_month, or select\_year by defaults have  
> a field name of “date[day]”, “date[month]”, and “date[year]”  
> respectively. Well, I want to change it to be as simply as “day”,  
> “month”, and “year”. Do rails have a built in function to do that?
> 
> In the documentation, I found a :field\_name option, but it does not meet  
> my need (the format is still “date[field\_name]”).

Rails does that so it can reconstitute them into a date attribute  
properly.

If you really want three separate parameters then why not just use  
regular select\_tag helpers and give them whatever names you want, rather  
than fiddling with overriding the behavior of the date\_select helpers.

---

<div class="post-metadata">

**Author:** ![ang89](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@ang89](https://www.ruby-forum.com/u/ang89)\
**Post date:** [February 19, 2010, 9:15am UTC](https://www.ruby-forum.com/t/change-field-name-of-select-day-select-month/183710/3 "2010-02-19T09:15:41Z")

</div>

Robert W. wrote:

> Rails does that so it can reconstitute them into a date attribute  
> properly.
> 
> If you really want three separate parameters then why not just use  
> regular select\_tag helpers and give them whatever names you want, rather  
> than fiddling with overriding the behavior of the date\_select helpers.

That’s OK. I just want to make sure if that functionality is available.  
Thanks!

---

<div class="post-metadata">

**Author:** ![ang89](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@ang89](https://www.ruby-forum.com/u/ang89)\
**Post date:** [November 17, 2011, 7:03pm UTC](https://www.ruby-forum.com/t/change-field-name-of-select-day-select-month/183710/4 "2011-11-17T19:03:44Z")

</div>

I know this thread is showing some age but if anyone else finds it  
looking for an answer I believe the solution is to use the :prefix  
option.

For example:  
select\_day Time.now, :field\_name =\> ‘production\_day’, :prefix =\> ‘film’

Produces:

Nick Gal  
ThinkLogic

---

<div class="post-metadata">

**Author:** ![ang89](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@ang89](https://www.ruby-forum.com/u/ang89)\
**Post date:** [February 20, 2010, 10:48am UTC](https://www.ruby-forum.com/t/change-field-name-of-select-day-select-month/183710/5 "2010-02-20T10:48:17Z")

</div>

add options name… like → :name =\> ‘date[now]’

On Fri, Feb 19, 2010 at 3:15 PM, Andree S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> –  
> [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

–

Senior Rails Developer  
Anton Effendi - Wu You Duan
