josh.rachner-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2009-Mar-31 23:28 UTC
datetime_select issues
I tried using this to build a datetime text box area: select_datetime (date = Time.now, :order => [:year, :month, :day]) This just returns a hash will the year, month, day, hour, minute. I also tried using datetime_select to do the same thing, but cant figure out how to capture the value of the input. Is there an easier way to do this?? Thanks, Josh --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
i''m not sure this is what you''re looking for, but there are a few ways to solve this: 1. use a text input field, e.g. form.text_field :model, :date_wanted and the user inputs a date e.g. 01/14/2009, rails will convert the input into the proper datetime (if your db field is of type: datetime). tip: you can use some js to have a calendar popup when the field is entered to allow users to click on a date. 2. if you want to use a select menu, you don''t have to worry about parsing the values in the controller--they''ll be magically parsed by AR upon save. just have the options'' values be real date names. e.g. March or 03, etc. AR also handles times, so if you input 12 AM, it will convert it to 0:00:00, etc. the advantage to your initial attempt at using a select menu is that it helps almost ensure properly input data, and screen readers can handle them clearly. hth On Mar 31, 7:28 pm, "josh.rach...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <josh.rach...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I tried using this to build a datetime text box area: select_datetime > (date = Time.now, :order => [:year, :month, :day]) > > This just returns a hash will the year, month, day, hour, minute. > > I also tried using datetime_select to do the same thing, but cant > figure out how to capture the value of the input. Is there an easier > way to do this?? > > Thanks, > > Josh--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---