SubForm.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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_SubForm */
  22. require_once 'Zend/Form/SubForm.php';
  23. /**
  24. * Dijit-enabled SubForm
  25. *
  26. * @uses Zend_Form_SubForm
  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_SubForm extends Zend_Form_SubForm
  34. {
  35. /**
  36. * Has the dojo view helper path been registered?
  37. * @var bool
  38. */
  39. protected $_dojoViewPathRegistered = false;
  40. /**
  41. * Constructor
  42. *
  43. * @param array|Zend_Config|null $options
  44. * @return void
  45. */
  46. public function __construct($options = null)
  47. {
  48. $this->addPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator')
  49. ->addPrefixPath('Zend_Dojo_Form_Element', 'Zend/Dojo/Form/Element', 'element')
  50. ->addElementPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator')
  51. ->addDisplayGroupPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator')
  52. ->setDefaultDisplayGroupClass('Zend_Dojo_Form_DisplayGroup');
  53. parent::__construct($options);
  54. }
  55. /**
  56. * Load the default decorators
  57. *
  58. * @return void
  59. */
  60. public function loadDefaultDecorators()
  61. {
  62. if ($this->loadDefaultDecoratorsIsDisabled()) {
  63. return;
  64. }
  65. $decorators = $this->getDecorators();
  66. if (empty($decorators)) {
  67. $this->addDecorator('FormElements')
  68. ->addDecorator('HtmlTag', array('tag' => 'dl'))
  69. ->addDecorator('ContentPane');
  70. }
  71. }
  72. /**
  73. * Get view
  74. *
  75. * @return Zend_View_Interface
  76. */
  77. public function getView()
  78. {
  79. $view = parent::getView();
  80. if (!$this->_dojoViewPathRegistered) {
  81. if (false === $view->getPluginLoader('helper')->getPaths('Zend_Dojo_View_Helper')) {
  82. $view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper');
  83. }
  84. $this->_dojoViewPathRegistered = true;
  85. }
  86. return $view;
  87. }
  88. }