Form.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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_View
  17. * @subpackage Helper
  18. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @version $Id$
  20. * @license http://framework.zend.com/license/new-bsd New BSD License
  21. */
  22. /** Zend_View_Helper_FormElement */
  23. require_once 'Zend/View/Helper/FormElement.php';
  24. /**
  25. * Helper for rendering HTML forms
  26. *
  27. * @package Zend_View
  28. * @subpackage Helper
  29. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  30. * @license http://framework.zend.com/license/new-bsd New BSD License
  31. */
  32. class Zend_View_Helper_Form extends Zend_View_Helper_FormElement
  33. {
  34. /**
  35. * Render HTML form
  36. *
  37. * @param string $name Form name
  38. * @param null|array $attribs HTML form attributes
  39. * @param false|string $content Form content
  40. * @return string
  41. */
  42. public function form($name, $attribs = null, $content = false)
  43. {
  44. $info = $this->_getInfo($name, $content, $attribs);
  45. extract($info);
  46. if (!empty($id)) {
  47. $id = ' id="' . $this->view->escape($id) . '"';
  48. } else {
  49. $id = '';
  50. }
  51. if (array_key_exists('id', $attribs) && empty($attribs['id'])) {
  52. unset($attribs['id']);
  53. }
  54. $xhtml = '<form'
  55. . $id
  56. . $this->_htmlAttribs($attribs)
  57. . '>';
  58. if (false !== $content) {
  59. $xhtml .= $content
  60. . '</form>';
  61. }
  62. return $xhtml;
  63. }
  64. }