Step 1:-
The first and most important step is to copy external ”dojo”
into your root folder of site.
Your file structure some thing like this after copied dojo folder.
Step 2:-
After you copy the dojo folder add the following code in
your bootstrap file.
$view->addHelperPath('Zend/Dojo/View/Helper/',
'Zend_Dojo_View_Helper');
Means you have to add path to Dojo view helpers on your
bootstrap file.
After changes your bootstrap contain following lines.
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function
_initDoctype()
{
$this->bootstrap('view');
$view =
$this->getResource('view');
$view->doctype('XHTML1_STRICT');
$view->addHelperPath('Zend/Dojo/View/Helper/',
'Zend_Dojo_View_Helper');
$viewRenderer
= new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);
}
}
Step 3 :-
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.
<?php
$this->dojo()->setDjConfigOption('usePlainJson', true)
->addStylesheetModule('dijit.themes.tundra')
->setLocalPath("http://localhost/zend/dojo/dojo/dojo.js");
echo
$this->dojo();
?>
The only thing you need to do is to enable dojo in your
template file.
Your configuration is now completed.
Now create your form as follows.
Dojo Editor example after configuration
<?php
class Application_Form_Inquery extends Zend_Form
{
public function init() {
// Dojo-enable the form:
Zend_Dojo::enableForm($this);
// Dojo-enable all sub forms:
foreach ($this->getSubForms() as $subForm) {
Zend_Dojo::enableForm($subForm);
}
//parent::__construct($options);
// Set the method for the display form to POST
$this->setMethod('post');
// Add an company name element
$this->addElement('text', 'company_name', array(
'label' => 'Company name:',
'required' => true,
'filters' => array('StringTrim'),
));
// Add the contact_person_name element
$this->addElement('text', 'contact_person_name', array(
'label' => 'Contact person name:',
'required' => true,
));
// Add the phone_no element
$this->addElement('text', 'phone_no', array(
'label' => 'Phone no:',
'required' => true,
));
// Add the ext element
$this->addElement('text', 'ext', array(
'label' => 'Ext:',
'required' => false,
));
// Add the email element
$this->addElement('text', 'email', array(
'label' => 'Email:',
'required' => true,
));
// Add the country element
$this->addElement('text', 'country', array(
'label' => 'Country:',
'required' => true,
));
// Add the Description element
/*$this->addElement('textarea', 'description', array(
'label' => 'Description:',
'required' => true,
));*/
$this->addElement('editor', 'description', array(
'label'=>'Description',
//'extraPlugins' => array('undo', '|', 'bold', 'italic','fontName', 'fontSize', ),
'editActionInterval' => 2,
'focusOnLoad' => false,
'height' => '250px',
'inheritWidth' => true,
//'styleSheets' => array('../dojo/dojox/editor/plugins/resources/editorPlugins.css'),
));
// Add a captcha
$this->addElement('captcha', 'captcha', array(
'required' => true,
'label' => 'Captcha',
'captcha' => array(
'captcha' => 'Dumb',
'wordLen' => 5,
'timeout' => 300
)
));
// Add the submit button
$this->addElement('submit', 'submit', array(
'ignore' => true,
'label' => 'Submit',
));
// Add the reset button
$this->addElement('reset', 'reset', array(
'ignore' => true,
'label' => 'Reset',
));
// And finally add some CSRF protection
$this->addElement('hash', 'csrf', array(
'ignore' => true,
));
}
}
?>