File indexing completed on 2024-05-12 06:02:27

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Dojo
0017  * @subpackage Form
0018  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0019  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0020  */
0021 
0022 /** Zend_Form */
0023 // require_once 'Zend/Form.php';
0024 
0025 /**
0026  * Dijit-enabled Form
0027  *
0028  * @uses       Zend_Form
0029  * @package    Zend_Dojo
0030  * @subpackage Form
0031  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0032  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0033  * @version    $Id$
0034  */
0035 class Zend_Dojo_Form extends Zend_Form
0036 {
0037     /**
0038      * Constructor
0039      *
0040      * @param  array|Zend_Config|null $options
0041      * @return void
0042      */
0043     public function __construct($options = null)
0044     {
0045         $this->addPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator')
0046              ->addPrefixPath('Zend_Dojo_Form_Element', 'Zend/Dojo/Form/Element', 'element')
0047              ->addElementPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator')
0048              ->addDisplayGroupPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator')
0049              ->setDefaultDisplayGroupClass('Zend_Dojo_Form_DisplayGroup');
0050         parent::__construct($options);
0051     }
0052 
0053     /**
0054      * Load the default decorators
0055      *
0056      * @return void
0057      */
0058     public function loadDefaultDecorators()
0059     {
0060         if ($this->loadDefaultDecoratorsIsDisabled()) {
0061             return;
0062         }
0063 
0064         $decorators = $this->getDecorators();
0065         if (empty($decorators)) {
0066             $this->addDecorator('FormElements')
0067                  ->addDecorator('HtmlTag', array('tag' => 'dl', 'class' => 'zend_form_dojo'))
0068                  ->addDecorator('DijitForm');
0069         }
0070     }
0071 
0072     /**
0073      * Set the view object
0074      *
0075      * Ensures that the view object has the dojo view helper path set.
0076      *
0077      * @param  Zend_View_Interface $view
0078      * @return Zend_Dojo_Form_Element_Dijit
0079      */
0080     public function setView(Zend_View_Interface $view = null)
0081     {
0082         if (null !== $view) {
0083             if (false === $view->getPluginLoader('helper')->getPaths('Zend_Dojo_View_Helper')) {
0084                 $view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper');
0085             }
0086         }
0087         return parent::setView($view);
0088     }
0089 }