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