File indexing completed on 2025-03-02 05:29:58
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_View 0017 * @subpackage Helper 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @version $Id$ 0020 * @license http://framework.zend.com/license/new-bsd New BSD License 0021 */ 0022 0023 /** Zend_View_Helper_FormElement */ 0024 // require_once 'Zend/View/Helper/FormElement.php'; 0025 0026 /** 0027 * Helper for rendering HTML forms 0028 * 0029 * @package Zend_View 0030 * @subpackage Helper 0031 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0032 * @license http://framework.zend.com/license/new-bsd New BSD License 0033 */ 0034 class Zend_View_Helper_Form extends Zend_View_Helper_FormElement 0035 { 0036 /** 0037 * Render HTML form 0038 * 0039 * @param string $name Form name 0040 * @param null|array $attribs HTML form attributes 0041 * @param false|string $content Form content 0042 * @return string 0043 */ 0044 public function form($name, $attribs = null, $content = false) 0045 { 0046 $info = $this->_getInfo($name, $content, $attribs); 0047 extract($info); 0048 0049 if (!empty($id)) { 0050 $id = ' id="' . $this->view->escape($id) . '"'; 0051 } else { 0052 $id = ''; 0053 } 0054 0055 if (array_key_exists('id', $attribs) && empty($attribs['id'])) { 0056 unset($attribs['id']); 0057 } 0058 0059 if (!empty($name) && !($this->_isXhtml() && $this->_isStrictDoctype())) { 0060 $name = ' name="' . $this->view->escape($name) . '"'; 0061 } else { 0062 $name = ''; 0063 } 0064 0065 if ($this->_isHtml5() && array_key_exists('action', $attribs) && !$attribs['action']) { 0066 unset($attribs['action']); 0067 } 0068 0069 if ( array_key_exists('name', $attribs) && empty($attribs['id'])) { 0070 unset($attribs['id']); 0071 } 0072 0073 $xhtml = '<form' 0074 . $id 0075 . $name 0076 . $this->_htmlAttribs($attribs) 0077 . '>'; 0078 0079 if (false !== $content) { 0080 $xhtml .= $content 0081 . '</form>'; 0082 } 0083 0084 return $xhtml; 0085 } 0086 }