Change field name of select_day, select_month ..

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

Andree Surya 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.

Robert Walker 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!

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

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:
<select id="film_production_day" name="film[production_day]">

Nick Gal
ThinkLogic