andimeier-hi6Y0CQ0nG0@public.gmane.org
2007-Jan-11 14:05 UTC
text field as date selector (not comboboxes) => how to create customized form helpers?
Having to set 6 comboboxes just to enter a date/time is simply overkill to me. I prefer a simple text field where I can (e.g. for date input fields) input strings like 2007-12-02 +3 (remark: means the date of 3 days after today) 12-05 (remark: will be completed with the current year) I already have implemented the functionality of parsing these dates, but now I am not sure how to integrate it into the Rails framework (plugin mechanism?). Does anybody know how to do this? Is there some documentation about writing own form helpers like this? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mick Sharpe
2007-Jan-11 22:55 UTC
Re: text field as date selector (not comboboxes) => how to c
Check out the DateBocks plugin at http://datebocks.inimit.com/ :) -- 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-/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 -~----------~----~----~----~------~----~------~--~---
Bojan Mihelac
2007-Jan-15 15:22 UTC
Re: text field as date selector (not comboboxes) => how to create customized form helpers?
andimeier-hi6Y0CQ0nG0@public.gmane.org wrote:> Having to set 6 comboboxes just to enter a date/time is simply overkill > to me. I prefer a simple text field where I can (e.g. for date input > fields) input strings like > 2007-12-02 > +3 (remark: means the date of 3 days after today) > 12-05 (remark: will be completed with the current year) > > I already have implemented the functionality of parsing these dates, > but now I am not sure how to integrate it into the Rails framework > (plugin mechanism?). > > Does anybody know how to do this? Is there some documentation about > writing own form helpers like this? > > > > > > >I use this to display and parse european dates (dd.mm.yyyy). module ActionView # :nodoc: module Helpers # :nodoc: class InstanceTag def to_date_select_tag(options = {}) #to_input_field_tag(''text'', {''size''=>''10''}.merge(options)) options = options.stringify_keys options["size"] ||= options["maxlength"] || DEFAULT_FIELD_OPTIONS["size"] options = DEFAULT_FIELD_OPTIONS.merge(options) options["type"] = ''text'' options["value"] ||= value.to_formatted_s(options["date_format"] || :input_format) if value.kind_of?(Date) add_default_name_and_id(options) tag("input", options) end end end end require (''parsedate'') module ParseDate class << self alias_method :old_parsedate, :parsedate unless method_defined?(:old_parsedate) end def self.parsedate(str) match = /(\d{1,2})\.(\d{1,2})\.(\d{2,4})\.?/.match(str) return ParseDate.old_parsedate(str) unless match [match[3].to_i, match[2].to_i, match[1].to_i, nil, nil, nil, nil, nil] end end -- Bojan Mihelac Informatika Mihelac, Bojan Mihelac s.p. | www.informatikamihelac.com -> tools, scripts, tricks from our code lab: http://source.mihelac.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---