Recently I come across a problem using third party “calendar”- Java script Calendar, and as Zend has now done collaboration with Dojo, so people using zend will definitely start using Dojo for java scripts and all other functionality Dojo is providing. And that’s why I decided to study and use Dojo and implement it in my application instead of fixing the issue in the third party calendar.
Although Zend has done excellent job and has made things quite easy for those who wish to use dojo in their applications, however novice and those with little experience may find it a bit difficult to configure Zend for Dojo.
It this post I will tell you how to configure Zend for working with Dojo.
The first and most important thing is to copy “external/dojo” into your js directory under www/public folder.
After you copy the dojo folder add the following code in your bootstrap.
$view = new Zend_View();
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
Ignore the first line $view= new Zend_View() if you have already instantiated view object in your bootstrap file.
That’s it. You have now added path to Dojo view helpers. You can now access dojo view helpers in your template-phtml file as you access other helper files and their functionality.
You job has not done yet.
Next you would need to add path to dojo.js file and other module of the dojo toolkit.
So open your layout file and put following code.
As you can see we are adding path to js and stylesheet files so put the above code in <head> tag of your layout file.
The only thing you need to do is to enable dojo in your template file.
Let suppose you have controller “IndexController”. So in the views/scripts/index/index.phtml file put the following code.
I would like to explain the last line ->requireModule(’dijit.form.DateTextBox’). This line tells php to load DateTextBox. DateTextBox render textbox that display calendar when someone click on the field.
Your configuration is now completed. Now create your form as follows.
class MyForm extends Zend_Dojo_Form
public function init()
'label' => 'Date:',
'required' => true,
'invalidMessage' => 'Invalid date specified.',
'formatLength' => 'long',
In your controller, write
$form= new MyForm();
In your view template
The last thing I’d mention is, In your layout file replace “body” tag with