Hello, I need to accept dates in a form using a text_field and not a date_select. Why? Well, because for users it''s faster to type a date. But if I enter a simple date like "13/05/2012" (dd/mm/yyyy format), when I want to edit this register, in the text_field appears "2012-05-13". How can I change this behavior, so in the text_field appears "13/05/2012"? Thank you! -- 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.
Hello, You might want to check out this http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html :order - Set to an array containing :day, :month and :year to customize the order in which the select fields are shown. If you leave out any of the symbols, the respective select will not be shown (like when you set :discard_xxx => true. Defaults to the order defined in the respective locale (e.g. [:year, :month, :day] in the en locale that ships with Rails<http://api.rubyonrails.org/classes/Rails.html>) :date_separator - Specifies a string to separate the date fields. Default is "" (i.e. nothing). Best regards On Thu, Jun 14, 2012 at 7:23 PM, Marc C. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hello, > > I need to accept dates in a form using a text_field and not a > date_select. Why? Well, because for users it''s faster to type a date. > > But if I enter a simple date like "13/05/2012" (dd/mm/yyyy format), when > I want to edit this register, in the text_field appears "2012-05-13". > > How can I change this behavior, so in the text_field appears > "13/05/2012"? > > Thank you! > > -- > 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. > >-- 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.
And this: http://jqueryui.com/demos/datepicker/ On Sat, Jun 16, 2012 at 9:41 AM, Ermin Dedovic <ermin.dedovic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> Hello, > > You might want to check out this > http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html > > :order - Set to an array containing :day, :month and :year to customize > the order in which the select fields are shown. If you leave out any of the > symbols, the respective select will not be shown (like when you set :discard_xxx > => true. Defaults to the order defined in the respective locale (e.g. > [:year, :month, :day] in the en locale that ships with Rails<http://api.rubyonrails.org/classes/Rails.html>) > > :date_separator - Specifies a string to separate the date fields. Default > is "" (i.e. nothing). > > Best regards > > > > On Thu, Jun 14, 2012 at 7:23 PM, Marc C. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > >> Hello, >> >> I need to accept dates in a form using a text_field and not a >> date_select. Why? Well, because for users it''s faster to type a date. >> >> But if I enter a simple date like "13/05/2012" (dd/mm/yyyy format), when >> I want to edit this register, in the text_field appears "2012-05-13". >> >> How can I change this behavior, so in the text_field appears >> "13/05/2012"? >> >> Thank you! >> >> -- >> 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. >> >> >-- 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.
Hi Marc,>> On Thu, Jun 14, 2012 at 7:23 PM, Marc C. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> >>> Hello, >>> >>> I need to accept dates in a form using a text_field and not a >>> date_select. Why? Well, because for users it''s faster to type a date. >>> >>> But if I enter a simple date like "13/05/2012" (dd/mm/yyyy format), when >>> I want to edit this register, in the text_field appears "2012-05-13". >>> >>> How can I change this behavior, so in the text_field appears >>> "13/05/2012"? >>> >>> Thank you! >>>You can use the #strftime method to easily accomplish what you want. ruby-1.9.2-p290 :001 > require ''date'' => true ruby-1.9.2-p290 :002 > d = Date.parse(''2012-05-13'') => #<Date: 2012-05-13 (4912121/2,0,2299161)> ruby-1.9.2-p290 :003 > d.strftime(''%d/%m/%Y'') => "13/05/2012" HTH, Bill -- 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.