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

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!

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

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

On Fri, Feb 19, 2010 at 3:15 PM, Andree S. [email protected]alid
wrote:


http://groups.google.com/group/rubyonrails-talk?hl=en.

Senior Rails Developer
Anton Effendi - Wu You Duan

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs