Form.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 View
  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. * @version $Id$
  21. */
  22. /** Zend_Dojo_View_Helper_Dijit */
  23. require_once 'Zend/Dojo/View/Helper/Dijit.php';
  24. /**
  25. * Dojo Form dijit
  26. *
  27. * @uses Zend_Dojo_View_Helper_Dijit
  28. * @package Zend_Dojo
  29. * @subpackage View
  30. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http://framework.zend.com/license/new-bsd New BSD License
  32. */
  33. class Zend_Dojo_View_Helper_Form extends Zend_Dojo_View_Helper_Dijit
  34. {
  35. /**
  36. * Dijit being used
  37. * @var string
  38. */
  39. protected $_dijit = 'dijit.form.Form';
  40. /**
  41. * Module being used
  42. * @var string
  43. */
  44. protected $_module = 'dijit.form.Form';
  45. /**
  46. * @var Zend_View_Helper_Form
  47. */
  48. protected $_helper;
  49. /**
  50. * dijit.form.Form
  51. *
  52. * @param string $id
  53. * @param null|array $attribs HTML attributes
  54. * @param false|string $content
  55. * @return string
  56. */
  57. public function form($id, $attribs = null, $content = false)
  58. {
  59. if (!is_array($attribs)) {
  60. $attribs = (array) $attribs;
  61. }
  62. if (array_key_exists('id', $attribs)) {
  63. $attribs['name'] = $id;
  64. } else {
  65. $attribs['id'] = $id;
  66. }
  67. $attribs = $this->_prepareDijit($attribs, array(), 'layout');
  68. return $this->getFormHelper()->form($id, $attribs, $content);
  69. }
  70. /**
  71. * Get standard form helper
  72. *
  73. * @return Zend_View_Helper_Form
  74. */
  75. public function getFormHelper()
  76. {
  77. if (null === $this->_helper) {
  78. require_once 'Zend/View/Helper/Form.php';
  79. $this->_helper = new Zend_View_Helper_Form;
  80. $this->_helper->setView($this->view);
  81. }
  82. return $this->_helper;
  83. }
  84. }