Bare bones date picker for Merb

I’ve been fooling around with Merb these past few months. Can’t say I’ve created anything of consequence, but along the way I’d written this simple date picker, and thought I’d share it.

Used inside a form_for block, it creates 3 separate drop-downs for year, month, and day from a Time object.

Example:

<% form_for @person %>

  <%= date_control :birthdate, :label => 'Birthdate' %>

<% end %>

	

Note: This should be run against Merb 0.9.3.

Commentary

Substantial!

Comment by anonymous on July 10, 2008

nice! is there a way to do :selected => nil so that the entire date field gets nil. this is what i want to do so that the default of the end_date for a featured item is nil and then i’ll say if it’s nil then the item is featured forever. i don’t really understand the merb code… but it seems like selected has not been implemented yet… how can i do this?

Comment by Matt on August 11, 2008

I’ve updated the helper for the latest merb 0.9.6 form helpers here: http://gist.github.com/7324

Comment by Jamie Macey on August 26, 2008

Thanks Jamie.

Comment by Ben on August 27, 2008

Post a comment

(required)

(required)