Digital Base – Blog » forms

using dbFormExtraPlugin for datepicker or datetimepicker

Posted by Gijs Nelissen in All, Programming

For an internal web development project i was looking for a good date picker. I bounced onto sfFormExtraPlugin, but it took me a while to find the correct jquery & jquery UI css & javascript files and set the paths. I decided to create my owner datepicker based on the one in sfFormExtraPlugin (which was based on the jQuery UI Datepicker).

As we already had a plugin containing some of the widgets/validators we are using for some of our webdesign projects, i decided to include those widgets into the existing one named dbFormExtraPlugin, original name, i know…

Installing dbFormExtraPlugin

It’s really this simple, install, publish assets, en clear your cache.

symfony plugin:install dbFormExtraPlugin --release=0.0.5
symfony plugin:publish-assets
symfony cache:clear

sfWidgetFormDateJQuery

This is based on the normal jQuery date picker

class ProjectForm extends BaseProjectForm
{
  public function configure()
  {
 
      $this->widgetSchema['published_at'] = new sfWidgetFormDateJQuery();
  }
}

Should give you something like this

sfwidgetformdatejquery

sfWidgetFormDateTimeDyn

This is based on the dyndatetime project, something i found on google code. From their website :

jQuery has lots of date pickers, but no date- time pickers. This supports date and time, and renders the value to a single field in a configurable format.

Use it like this

class ProjectForm extends BaseProjectForm
{
  public function configure()
  {
      $this->widgetSchema['featured_at'] = new sfWidgetFormDateTimeDyn();
  }
}

Results in a popup, similar to the dynarch calendar picker, including time sliding capabilities !

sfwidgetformdatetimedyn

I still have some work todo on configuration/customisation but it does work (out of the box).
Other installation instructions here. Comments welcome. Leave a message on this post, post a bugticket on the symfony trac or contact us by email.