2
0

Form.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /** Zend_Form */
  22. require_once 'Zend/Form.php';
  23. /**
  24. * Dijit-enabled Form
  25. *
  26. * @uses Zend_Form
  27. * @package Zend_Dojo
  28. * @subpackage Form
  29. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  30. * @license http://framework.zend.com/license/new-bsd New BSD License
  31. * @version $Id$
  32. */
  33. class Zend_Dojo_Form extends Zend_Form
  34. {
  35. /**
  36. * Constructor
  37. *
  38. * @param array|Zend_Config|null $options
  39. * @return void
  40. */
  41. public function __construct($options = null)
  42. {
  43. $this->addPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator')
  44. ->addPrefixPath('Zend_Dojo_Form_Element', 'Zend/Dojo/Form/Element', 'element')
  45. ->addElementPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator')
  46. ->addDisplayGroupPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator')
  47. ->setDefaultDisplayGroupClass('Zend_Dojo_Form_DisplayGroup');
  48. parent::__construct($options);
  49. }
  50. /**
  51. * Load the default decorators
  52. *
  53. * @return void
  54. */
  55. public function loadDefaultDecorators()
  56. {
  57. if ($this->loadDefaultDecoratorsIsDisabled()) {
  58. return;
  59. }
  60. $decorators = $this->getDecorators();
  61. if (empty($decorators)) {
  62. $this->addDecorator('FormElements')
  63. ->addDecorator('HtmlTag', array('tag' => 'dl', 'class' => 'zend_form_dojo'))
  64. ->addDecorator('DijitForm');
  65. }
  66. }
  67. /**
  68. * Set the view object
  69. *
  70. * Ensures that the view object has the dojo view helper path set.
  71. *
  72. * @param Zend_View_Interface $view
  73. * @return Zend_Dojo_Form_Element_Dijit
  74. */
  75. public function setView(Zend_View_Interface $view = null)
  76. {
  77. if (null !== $view) {
  78. if (false === $view->getPluginLoader('helper')->getPaths('Zend_Dojo_View_Helper')) {
  79. $view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper');
  80. }
  81. }
  82. return parent::setView($view);
  83. }
  84. }