web/Zend/Dojo/Form.php
changeset 0 4eba9c11703f
equal deleted inserted replaced
-1:000000000000 0:4eba9c11703f
       
     1 <?php
       
     2 /**
       
     3  * Zend Framework
       
     4  *
       
     5  * LICENSE
       
     6  *
       
     7  * This source file is subject to the new BSD license that is bundled
       
     8  * with this package in the file LICENSE.txt.
       
     9  * It is also available through the world-wide-web at this URL:
       
    10  * http://framework.zend.com/license/new-bsd
       
    11  * If you did not receive a copy of the license and are unable to
       
    12  * obtain it through the world-wide-web, please send an email
       
    13  * to license@zend.com so we can send you a copy immediately.
       
    14  *
       
    15  * @category   Zend
       
    16  * @package    Zend_Dojo
       
    17  * @subpackage Form
       
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  */
       
    21 
       
    22 /** Zend_Form */
       
    23 require_once 'Zend/Form.php';
       
    24 
       
    25 /**
       
    26  * Dijit-enabled Form
       
    27  *
       
    28  * @uses       Zend_Form
       
    29  * @package    Zend_Dojo
       
    30  * @subpackage Form
       
    31  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    32  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    33  * @version    $Id: Form.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    34  */
       
    35 class Zend_Dojo_Form extends Zend_Form
       
    36 {
       
    37     /**
       
    38      * Constructor
       
    39      *
       
    40      * @param  array|Zend_Config|null $options
       
    41      * @return void
       
    42      */
       
    43     public function __construct($options = null)
       
    44     {
       
    45         $this->addPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator')
       
    46              ->addPrefixPath('Zend_Dojo_Form_Element', 'Zend/Dojo/Form/Element', 'element')
       
    47              ->addElementPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator')
       
    48              ->addDisplayGroupPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator')
       
    49              ->setDefaultDisplayGroupClass('Zend_Dojo_Form_DisplayGroup');
       
    50         parent::__construct($options);
       
    51     }
       
    52 
       
    53     /**
       
    54      * Load the default decorators
       
    55      *
       
    56      * @return void
       
    57      */
       
    58     public function loadDefaultDecorators()
       
    59     {
       
    60         if ($this->loadDefaultDecoratorsIsDisabled()) {
       
    61             return;
       
    62         }
       
    63 
       
    64         $decorators = $this->getDecorators();
       
    65         if (empty($decorators)) {
       
    66             $this->addDecorator('FormElements')
       
    67                  ->addDecorator('HtmlTag', array('tag' => 'dl', 'class' => 'zend_form_dojo'))
       
    68                  ->addDecorator('DijitForm');
       
    69         }
       
    70     }
       
    71 
       
    72     /**
       
    73      * Set the view object
       
    74      *
       
    75      * Ensures that the view object has the dojo view helper path set.
       
    76      *
       
    77      * @param  Zend_View_Interface $view
       
    78      * @return Zend_Dojo_Form_Element_Dijit
       
    79      */
       
    80     public function setView(Zend_View_Interface $view = null)
       
    81     {
       
    82         if (null !== $view) {
       
    83             if (false === $view->getPluginLoader('helper')->getPaths('Zend_Dojo_View_Helper')) {
       
    84                 $view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper');
       
    85             }
       
    86         }
       
    87         return parent::setView($view);
       
    88     }
       
    89 }