Forum: Ruby on Rails text field as date selector (not comboboxes) => how to creat

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
4900d0b180e9b9070a14fe78a698c0a4?d=identicon&s=25 (Guest)
on 2007-01-11 15:08
(Received via mailing list)
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
  +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?
F5c118aaeb5bb7162db613a37e595be8?d=identicon&s=25 Mick Sharpe (micksharpe)
on 2007-01-11 23:55
Check out the DateBocks plugin at :)
866edcb271e88be4bfd935eea7947730?d=identicon&s=25 Bojan Mihelac (Guest)
on 2007-01-15 16:35
(Received via mailing list) wrote:
> 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 (

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"] ||
         options = DEFAULT_FIELD_OPTIONS.merge(options)
         options["type"] = 'text'
         options["value"] ||=
value.to_formatted_s(options["date_format"] || :input_format) if
         tag("input", options)

require ('parsedate')
module ParseDate
   class << self
     alias_method :old_parsedate, :parsedate unless

   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,

Bojan Mihelac
Informatika Mihelac, Bojan Mihelac s.p.  |
-> tools, scripts, tricks from our code lab:
This topic is locked and can not be replied to.