4

Zend Framework and JQuery: JQuery Date Picker

Nearly two months back I used dojo calendar in my application. Although dojo has extremely large library and provide very nice widgets like number spinner, horizontal scroller and more importantly gird, however the current calendar available is not good looking and provide only basic functionality. We were using JACS calendar before using dojo calendar in our application.

After working for a bit of time with dojo calendar we feel that we need JACS type calendar. We were looking for the latest dojo release for getting calendar with more functionality.

Today I find JQuery Date picker, which is similar to the JACS. As Zend Framework latest version now provide JQuery View helper and Form elements, so I decided to write article on it, so that developers using JQuery may find some useful information.

So lets look how to develop a nice and cool JQuery date picker.

At the end of this article we will have a calendar like the following.

First of all download the latest version of Zend framework and placed “ZendX” folder in the library/ directory. The same library/ directory where your Zend folder reside.

Now to create the above calendar we will first need to write the following code in our bootstrap file.

$view= new Zend_View();

$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();

$view->addHelperPath(’ZendX/JQuery/View/Helper/’, ‘ZendX_JQuery_View_Helper’);

$viewRenderer->setView($view);

Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);

Here we are initializing our Zend_View object (don’t initialize it if you have already done in bootstrap file).

Next we initialize Zend_Cotroller_Action_Helper_ViewRendere object and add helper path.

At the end we set view to viewRenderer and add helper to the Zend_Controller_Action_HelperBroker.

That’s it we have now setup our environment.

Next we enable JQuery in our layout file as

$this->jQuery()->setLocalPath('http://localhost/zend/js/jquery/jquery-1.2.6.js')

               ->addStylesheet('http://localhost/zend/js/jquery/themes/ui.datepicker.css');
echo $this->jQuery();

we are setting path to the jquery js file and datepicker css file.
Next in the view template file

Pick your Date: <?= $this->datePicker("dp1",
                            '',
                        array('defaultDate' => date('Y/m/d', time()))); ?>

That’s it. Nice and beautiful JQuery data picker.

Cheers.

Filed in: JQuery, Zend Framewrork Tags: ,

4 Responses to "Zend Framework and JQuery: JQuery Date Picker"

  1. Soumyadyuti Paul says:

    Hi,
    I followed the same process as you have suggested I am getting an error "Method 'JQuery' does not exist and was not trapped in _call()". Please help.

  2. Faheem Abbas says:

    Please download latest version of zend framework and copy ZendX/ directory from your downloaded folder/extras/ to your library/ directory.
    This may help you out.

  3. Anonymous says:

    Hi
    i get the error Message: Plugin by name 'DatePicker' was not found in the registry; used paths: Zend_View_Helper_: Zend/View/Helper/:./views/helpers/:/var/www/html/cpflead/application/views/helpers/

    please help me.

  4. Gaby says:

    Hi,

    Please, could you put the application'structure and where have to put the scripts?

Leave a Reply

Submit Comment

© 9436 Faheem Abbas. All rights reserved. XHTML / CSS Valid.
Proudly designed by Theme Junkie.
Top Footer