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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
anton effendi
2010-Feb-20 09:46 UTC
Re: Re: Change field name of select_day, select_month ..
add options name.. like --> :name => ''date[now]'' On Fri, Feb 19, 2010 at 3:15 PM, Andree Surya <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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! > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- Senior Rails Developer Anton Effendi - Wu You Duan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.