Form.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 ZendX
  16. * @package ZendX_JQuery
  17. * @subpackage View
  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. * @version $Id$
  21. */
  22. require_once "Zend/Form.php";
  23. /**
  24. * Form Wrapper for jQuery-enabled forms
  25. *
  26. * @package ZendX_JQuery
  27. * @subpackage Form
  28. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  29. * @license http://framework.zend.com/license/new-bsd New BSD License
  30. */
  31. class ZendX_JQuery_Form extends Zend_Form
  32. {
  33. /**
  34. * Constructor
  35. *
  36. * @param array|Zend_Config|null $options
  37. * @return void
  38. */
  39. public function __construct($options = null)
  40. {
  41. $this->addPrefixPath('ZendX_JQuery_Form_Decorator', 'ZendX/JQuery/Form/Decorator', 'decorator')
  42. ->addPrefixPath('ZendX_JQuery_Form_Element', 'ZendX/JQuery/Form/Element', 'element')
  43. ->addElementPrefixPath('ZendX_JQuery_Form_Decorator', 'ZendX/JQuery/Form/Decorator', 'decorator')
  44. ->addDisplayGroupPrefixPath('ZendX_JQuery_Form_Decorator', 'ZendX/JQuery/Form/Decorator');
  45. parent::__construct($options);
  46. }
  47. /**
  48. * Set the view object
  49. *
  50. * Ensures that the view object has the jQuery view helper path set.
  51. *
  52. * @param Zend_View_Interface $view
  53. * @return ZendX_JQuery_Form
  54. */
  55. public function setView(Zend_View_Interface $view = null)
  56. {
  57. if (null !== $view) {
  58. if (false === $view->getPluginLoader('helper')->getPaths('ZendX_JQuery_View_Helper')) {
  59. $view->addHelperPath('ZendX/JQuery/View/Helper', 'ZendX_JQuery_View_Helper');
  60. }
  61. }
  62. return parent::setView($view);
  63. }
  64. }