< Home

Unobtrusive Datepicker for symfony - demo

A nice replacement for sfWidgetFormJqueryDate

Short story

To use with date selects named in symfony style (e.g. foo_day, foo_month, foo_year)

Just include jQuery UI stylesheet and javascripts, jQuery, and datepicker

You must have this image in /images/calendar.png

Have fun! :-)

download (tbz, 90 Kb)


/ :

Long story

The story began when I got unsatisfied by sfWidgetFormJqueryDate, found in sfFormExtraPlugin. It has several issues:

Well, it's really an ugly solution.

So, I decided to write my own. I started from this demo and I wrote my implementation of this completely unobtrusive calendar. You can use it by simply adding the required stylesheet and javascripts: it will add automagically a nice calendar near each of your date selects (just on the right of the year). The calendar png image (courtesy of famfamfam) must be in /images/ directory (unless you want to edit datepicker.js). Each empty date will be adjusted to current date, but not if date is inside a filter form (which is likely unwanted). You can also exclude specific selects from date adjust by adding a noauto class to year's select (see demo above). If you want a date select to be excluded (i.e., the calendar not displayed beside it), just add a nocal class to year's select (again, see demo above). If you need localization, see Datepicker options. Be aware of not modify dateFormat option in your localization file, it could be lead to unexpected behaviours. You can see a demo localized in Italian.

symfony roma